]> git.sur5r.net Git - u-boot/commitdiff
efi_memory: avoid NULL dereference in efi_free_pool
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>
Fri, 14 Jul 2017 17:12:39 +0000 (19:12 +0200)
committerAlexander Graf <agraf@suse.de>
Wed, 19 Jul 2017 12:14:41 +0000 (14:14 +0200)
If efi_free_pool is called with argument NULL an illegal memory
access occurs.

So let's check the parameter on entry.

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

index db2ae19f590d1beacfb104533e5807bf7c93b2a2..5c53aaafdb18e8efe8a8167e513bc5e231bb2eea 100644 (file)
@@ -379,6 +379,9 @@ efi_status_t efi_free_pool(void *buffer)
        efi_status_t r;
        struct efi_pool_allocation *alloc;
 
+       if (buffer == NULL)
+               return EFI_INVALID_PARAMETER;
+
        alloc = container_of(buffer, struct efi_pool_allocation, data);
        /* Sanity check, was the supplied address returned by allocate_pool */
        assert(((uintptr_t)alloc & EFI_PAGE_MASK) == 0);