efi_loader: avoid NULL dereference in efi_get_memory_map()

We should only dereference parameter memory_map_size after checking that
it is valid.

Fixes: 8e835554b3 ("efi_loader: check parameters of GetMemoryMap")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lime2-spi
Heinrich Schuchardt 6 years ago committed by Alexander Graf
parent 3748ed908f
commit fa995d0d94
  1. 4
      lib/efi_loader/efi_memory.c

@ -457,11 +457,13 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
efi_uintn_t map_size = 0;
int map_entries = 0;
struct list_head *lhandle;
efi_uintn_t provided_map_size = *memory_map_size;
efi_uintn_t provided_map_size;
if (!memory_map_size)
return EFI_INVALID_PARAMETER;
provided_map_size = *memory_map_size;
list_for_each(lhandle, &efi_mem)
map_entries++;

Loading…
Cancel
Save