diff options
| author | Ard Biesheuvel <ardb@kernel.org> | 2024-12-19 15:30:39 +0100 |
|---|---|---|
| committer | Ard Biesheuvel <ardb@kernel.org> | 2025-01-14 08:35:27 +0100 |
| commit | ad69b0b6f9954796875ee4faf6c16c9caca21999 (patch) | |
| tree | 76b025f3e4e516e8cd6ce3fd2702ac7728a76363 /drivers/firmware/efi/libstub/x86-stub.c | |
| parent | 90534e689d2e52202c276ade5cf1dfc13d9e116f (diff) | |
efi/libstub: Use cleanup helpers for freeing copies of the memory map
The EFI stub may obtain the memory map from the firmware numerous times,
and this involves doing a EFI pool allocation first, which needs to be
freed after use.
Streamline this using a cleanup helper, which makes the code easier to
follow.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers/firmware/efi/libstub/x86-stub.c')
| -rw-r--r-- | drivers/firmware/efi/libstub/x86-stub.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 014ccf36a065..893c3ce4f4cc 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -616,7 +616,7 @@ static efi_status_t allocate_e820(struct boot_params *params, struct setup_data **e820ext, u32 *e820ext_size) { - struct efi_boot_memmap *map; + struct efi_boot_memmap *map __free(efi_pool) = NULL; efi_status_t status; __u32 nr_desc; @@ -630,13 +630,14 @@ static efi_status_t allocate_e820(struct boot_params *params, EFI_MMAP_NR_SLACK_SLOTS; status = alloc_e820ext(nr_e820ext, e820ext, e820ext_size); + if (status != EFI_SUCCESS) + return status; } - if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY) && status == EFI_SUCCESS) - status = allocate_unaccepted_bitmap(nr_desc, map); + if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY)) + return allocate_unaccepted_bitmap(nr_desc, map); - efi_bs_call(free_pool, map); - return status; + return EFI_SUCCESS; } struct exit_boot_struct { |