Skip to content

Commit 4b2543f

Browse files
hagarhemardbiesheuvel
authored andcommitted
efi: libstub: only free priv.runtime_map when allocated
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>
1 parent cda30c6 commit 4b2543f

File tree

1 file changed

+2
-2
lines changed
  • drivers/firmware/efi/libstub

1 file changed

+2
-2
lines changed

drivers/firmware/efi/libstub/fdt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
335335

336336
fail:
337337
efi_free(fdt_size, fdt_addr);
338-
339-
efi_bs_call(free_pool, priv.runtime_map);
338+
if (!efi_novamap)
339+
efi_bs_call(free_pool, priv.runtime_map);
340340

341341
return EFI_LOAD_ERROR;
342342
}

0 commit comments

Comments
 (0)