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>
This commit is contained in:
Avnish Chouhan authored and Daniel Kiper committed 2025-12-21 16:41:46 +01:00
1 parent 09c512b8fa
commit 02cae1a357
1 file changed
+3
+3
View File
@@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath)
grub_add (sz, sizeof ("ieee1275/"), &sz))
{
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of device path"));
grub_free (p);
return NULL;
}
@@ -109,6 +110,8 @@ ofdisk_hash_add_real (char *devpath)
if (grub_add (grub_strlen (p->devpath), 3, &sz))
{
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of an open path"));
grub_free (p->grub_devpath);
grub_free (p);
return NULL;
}