]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: efi_dp_part_node check dp_alloc return value
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 6 Oct 2022 11:36:02 +0000 (13:36 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 6 Oct 2022 20:54:57 +0000 (22:54 +0200)
dp_alloc() may return NULL. This needs to be caught.

Fixes: 98d48bdf415e ("efi_loader: provide a function to create a partition node")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
lib/efi_loader/efi_device_path.c
lib/efi_loader/efi_disk.c

index ebffb771228f3ff1ccae89ba4ab4eb280ed72e7a..acae007f26f5be1401bb8bac762bb1ea08740908 100644 (file)
@@ -936,7 +936,8 @@ struct efi_device_path *efi_dp_part_node(struct blk_desc *desc, int part)
                dpsize = sizeof(struct efi_device_path_hard_drive_path);
        buf = dp_alloc(dpsize);
 
-       dp_part_node(buf, desc, part);
+       if (buf)
+               dp_part_node(buf, desc, part);
 
        return buf;
 }
index 39ea1a68a68374d8aa13c5d8ee0da3aa1aed4e06..79b28097b6ce1369b40c784abb027c4bde86d2d6 100644 (file)
@@ -415,6 +415,11 @@ static efi_status_t efi_disk_add_dev(
                struct efi_handler *handler;
                void *protocol_interface;
 
+               if (!node) {
+                       ret = EFI_OUT_OF_RESOURCES;
+                       goto error;
+               }
+
                /* Parent must expose EFI_BLOCK_IO_PROTOCOL */
                ret = efi_search_protocol(parent, &efi_block_io_guid, &handler);
                if (ret != EFI_SUCCESS)