Skip to content

Commit

Permalink
efi: libstub: only free priv.runtime_map when allocated
Browse files Browse the repository at this point in the history
priv.runtime_map is only allocated when efi_novamap is not set.
Otherwise, it is an uninitialized value.  In the error path, it is freed
unconditionally.  Avoid passing an uninitialized value to free_pool.
Free priv.runtime_map only when it was allocated.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: f80d260 ("efi: libstub: avoid efi_get_memory_map() for allocating the virt map")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
  • Loading branch information
Hagar Hemdan authored and Ard Biesheuvel committed Apr 29, 2024
1 parent cda30c6 commit 4b2543f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/firmware/efi/libstub/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,

fail:
efi_free(fdt_size, fdt_addr);

efi_bs_call(free_pool, priv.runtime_map);
if (!efi_novamap)
efi_bs_call(free_pool, priv.runtime_map);

return EFI_LOAD_ERROR;
}
Expand Down

0 comments on commit 4b2543f

Please sign in to comment.