diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2018-07-02 13:53:55 +0300 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-07-25 15:59:44 +0300 |
commit | 1fcb7ea28400aa69e157dc4b19c9667e96d3a033 (patch) | |
tree | d4b7e87306d12acf0fea25c237488ea6f40e25bf /lib/efi_loader/efi_memory.c | |
parent | 8e835554b36b57a32a59de643056723a01525c3b (diff) | |
download | u-boot-1fcb7ea28400aa69e157dc4b19c9667e96d3a033.tar.xz |
efi_loader: check map_key in ExitBootServices
The UEFI spec requires that the memory map key is checked in
ExitBootServices().
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader/efi_memory.c')
-rw-r--r-- | lib/efi_loader/efi_memory.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index bad8704269..967c3f733e 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -15,6 +15,8 @@ DECLARE_GLOBAL_DATA_PTR; +efi_uintn_t efi_memory_map_key; + struct efi_mem_list { struct list_head link; struct efi_mem_desc desc; @@ -160,9 +162,13 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, debug("%s: 0x%" PRIx64 " 0x%" PRIx64 " %d %s\n", __func__, start, pages, memory_type, overlap_only_ram ? "yes" : "no"); + if (memory_type >= EFI_MAX_MEMORY_TYPE) + return EFI_INVALID_PARAMETER; + if (!pages) return start; + ++efi_memory_map_key; newlist = calloc(1, sizeof(*newlist)); newlist->desc.type = memory_type; newlist->desc.physical_start = start; @@ -487,7 +493,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, } if (map_key) - *map_key = 0; + *map_key = efi_memory_map_key; return EFI_SUCCESS; } |