Skip to content

Commit 02cae1a

Browse files
Avnish ChouhanDaniel Kiper
authored andcommitted
disk/ieee1275/ofdisk: Fix memory leaks
In case of an overflow "p" and "p->grub_devpath" will not be freed. Fix both issues. Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com> Reviewed-by: Alec Brown <alec.r.brown@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
1 parent 09c512b commit 02cae1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

grub-core/disk/ieee1275/ofdisk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath)
9393
grub_add (sz, sizeof ("ieee1275/"), &sz))
9494
{
9595
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of device path"));
96+
grub_free (p);
9697
return NULL;
9798
}
9899

@@ -109,6 +110,8 @@ ofdisk_hash_add_real (char *devpath)
109110
if (grub_add (grub_strlen (p->devpath), 3, &sz))
110111
{
111112
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of an open path"));
113+
grub_free (p->grub_devpath);
114+
grub_free (p);
112115
return NULL;
113116
}
114117

0 commit comments

Comments
 (0)