]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: check parameters in memory allocation
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 2 Jul 2018 10:53:53 +0000 (12:53 +0200)
committerAlexander Graf <agraf@suse.de>
Wed, 25 Jul 2018 12:59:44 +0000 (14:59 +0200)
If no pointer is provided throw an error.

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

index 86edfc95f421c0195fd6a8f218dec98f080b2c9d..f5aecd4b417f3d5bc9388556e555d2ec32b61961 100644 (file)
@@ -293,6 +293,9 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
        efi_status_t r = EFI_SUCCESS;
        uint64_t addr;
 
+       if (!memory)
+               return EFI_INVALID_PARAMETER;
+
        switch (type) {
        case EFI_ALLOCATE_ANY_PAGES:
                /* Any page */
@@ -386,6 +389,9 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
        u64 num_pages = (size + sizeof(struct efi_pool_allocation) +
                         EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
 
+       if (!buffer)
+               return EFI_INVALID_PARAMETER;
+
        if (size == 0) {
                *buffer = NULL;
                return EFI_SUCCESS;