]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: efi_disk: check return value of calloc
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 26 Oct 2017 17:25:46 +0000 (19:25 +0200)
committerAlexander Graf <agraf@suse.de>
Fri, 1 Dec 2017 12:22:56 +0000 (13:22 +0100)
Calloc may return NULL. We should check the return value.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_disk.c

index e61dbc80580b61ae6e0351be68d77fd8eeca0eeb..c6f0d732c11274b484188288d4664f512f231a6a 100644 (file)
@@ -196,6 +196,15 @@ efi_fs_from_path(struct efi_device_path *fp)
        return diskobj->volume;
 }
 
+/*
+ * Create a device for a disk
+ *
+ * @name       not used
+ * @if_typename interface name for block device
+ * @desc       internal block device
+ * @dev_index   device index for block device
+ * @offset     offset into disk for simple partitions
+ */
 static void efi_disk_add_dev(const char *name,
                             const char *if_typename,
                             struct blk_desc *desc,
@@ -210,6 +219,10 @@ static void efi_disk_add_dev(const char *name,
                return;
 
        diskobj = calloc(1, sizeof(*diskobj));
+       if (!diskobj) {
+               printf("ERROR: Out of memory\n");
+               return;
+       }
 
        /* Fill in object data */
        diskobj->dp = efi_dp_from_part(desc, part);