Hi Heinrich, On Thu, 25 Jul 2024 at 10:38, Heinrich Schuchardt <xypron.g...@gmx.de> wrote: > > On 25.07.24 15:56, Simon Glass wrote: > > 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. > > The size of the memory map may exceed CONFIG_SYS_MALLOC_LEN which tends > to be astonishingly small: 1 MiB or less on many boards.
The memory map is typically <20 entries, isn't it? I can't see that using too much space. If EFI needs malloc() to be larger than 1MB, we could enforce that with Kconfig. Regards, Simon > > Best regards > > Heinrich > > > > > Signed-off-by: Simon Glass <s...@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; > > } > > } >