[PATCH 4/6] efi: Avoid pool allocation in efi_get_memory_map_alloc()
Simon Glass
sjg at chromium.org
Thu Jul 25 15:56:27 CEST 2024
This function returns the memory map, allocating memory for it. But it
can just use malloc() directly, rather than calling the pool allocator.
Update it.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
lib/efi_loader/efi_memory.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 087f4c88cdf..2945f5648c7 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -850,14 +850,13 @@ efi_status_t efi_get_memory_map_alloc(efi_uintn_t *map_size,
ret = efi_get_memory_map(map_size, *memory_map, NULL, NULL, NULL);
if (ret == EFI_BUFFER_TOO_SMALL) {
*map_size += sizeof(struct efi_mem_desc); /* for the map */
- ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, *map_size,
- (void **)memory_map);
- if (ret != EFI_SUCCESS)
- return ret;
+ *memory_map = malloc(*map_size);
+ if (!*memory_map)
+ return EFI_OUT_OF_RESOURCES;
ret = efi_get_memory_map(map_size, *memory_map,
NULL, NULL, NULL);
if (ret != EFI_SUCCESS) {
- efi_free_pool(*memory_map);
+ free(*memory_map);
*memory_map = NULL;
}
}
--
2.34.1
More information about the U-Boot
mailing list