efi_loader: efi_gop: check calloc return value
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 26 Oct 2017 17:25:45 +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 have to check the return value.

Fixes: be8d324191f efi_loader: Add GOP support
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_gop.c

index 411a8c9226154d922ddcc948c96f1ab7660f7c23..85b5391ed1de158feef3afffa0ee0b203bb626eb 100644 (file)
@@ -173,6 +173,10 @@ int efi_gop_register(void)
        }
 
        gopobj = calloc(1, sizeof(*gopobj));
+       if (!gopobj) {
+               printf("ERROR: Out of memory\n");
+               return 1;
+       }
 
        /* Fill in object data */
        gopobj->parent.protocols[0].guid = &efi_gop_guid;