]> git.sur5r.net Git - u-boot/commitdiff
efi_memory: do parameter checks first
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>
Fri, 21 Jul 2017 17:04:33 +0000 (19:04 +0200)
committerAlexander Graf <agraf@suse.de>
Mon, 24 Jul 2017 12:46:01 +0000 (14:46 +0200)
The parameter checks should be done first.

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

index 5c53aaafdb18e8efe8a8167e513bc5e231bb2eea..c56653f4978f2db0c32ef6faa9fe172d97390bbe 100644 (file)
@@ -407,6 +407,9 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
 
        map_size = map_entries * sizeof(struct efi_mem_desc);
 
+       if (provided_map_size < map_size)
+               return EFI_BUFFER_TOO_SMALL;
+
        *memory_map_size = map_size;
 
        if (descriptor_size)
@@ -415,9 +418,6 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
        if (descriptor_version)
                *descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION;
 
-       if (provided_map_size < map_size)
-               return EFI_BUFFER_TOO_SMALL;
-
        /* Copy list into array */
        if (memory_map) {
                /* Return the list in ascending order */