aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/firmware/efi/libstub/efi-stub-helper.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index d073e3946383..9bd9fbb5bea8 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -66,29 +66,25 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
66 unsigned long key; 66 unsigned long key;
67 u32 desc_version; 67 u32 desc_version;
68 68
69 *map_size = 0; 69 *map_size = sizeof(*m) * 32;
70 *desc_size = 0; 70again:
71 key = 0;
72 status = efi_call_early(get_memory_map, map_size, NULL,
73 &key, desc_size, &desc_version);
74 if (status != EFI_BUFFER_TOO_SMALL)
75 return EFI_LOAD_ERROR;
76
77 /* 71 /*
78 * Add an additional efi_memory_desc_t because we're doing an 72 * Add an additional efi_memory_desc_t because we're doing an
79 * allocation which may be in a new descriptor region. 73 * allocation which may be in a new descriptor region.
80 */ 74 */
81 *map_size += *desc_size; 75 *map_size += sizeof(*m);
82 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 76 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
83 *map_size, (void **)&m); 77 *map_size, (void **)&m);
84 if (status != EFI_SUCCESS) 78 if (status != EFI_SUCCESS)
85 goto fail; 79 goto fail;
86 80
81 *desc_size = 0;
82 key = 0;
87 status = efi_call_early(get_memory_map, map_size, m, 83 status = efi_call_early(get_memory_map, map_size, m,
88 &key, desc_size, &desc_version); 84 &key, desc_size, &desc_version);
89 if (status == EFI_BUFFER_TOO_SMALL) { 85 if (status == EFI_BUFFER_TOO_SMALL) {
90 efi_call_early(free_pool, m); 86 efi_call_early(free_pool, m);
91 return EFI_LOAD_ERROR; 87 goto again;
92 } 88 }
93 89
94 if (status != EFI_SUCCESS) 90 if (status != EFI_SUCCESS)