]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
disk/ieee1275/ofdisk: Call grub_ieee1275_close() when grub_malloc() fails
authorAlec Brown <alec.r.brown@oracle.com>
Wed, 22 Jan 2025 02:55:12 +0000 (02:55 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 13 Feb 2025 14:45:56 +0000 (15:45 +0100)
In the dev_iterate() function a handle is opened but isn't closed when
grub_malloc() returns NULL. We should fix this by closing it on error.

Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/ieee1275/ofdisk.c

index 4c5b89cbcb6bdf81d2a26c68497e2c3f528177ac..dbc0f1abad59cf430dcd33664cad54c27a1e56c5 100644 (file)
@@ -267,7 +267,10 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 
       buf = grub_malloc (sz);
       if (!buf)
-       return;
+       {
+         grub_ieee1275_close (ihandle);
+         return;
+       }
       bufptr = grub_stpcpy (buf, alias->path);
 
       for (i = 0; i < args.nentries; i++)