kernel_samsung_a53x/drivers/firmware/efi
Ard Biesheuvel 2aa6501b2f efi/x86: Free EFI memory map only when installing a new one.
[ Commit 75dde792d6f6c2d0af50278bd374bf0c512fe196 upstream ]

The logic in __efi_memmap_init() is shared between two different
execution flows:
- mapping the EFI memory map early or late into the kernel VA space, so
  that its entries can be accessed;
- the x86 specific cloning of the EFI memory map in order to insert new
  entries that are created as a result of making a memory reservation
  via a call to efi_mem_reserve().

In the former case, the underlying memory containing the kernel's view
of the EFI memory map (which may be heavily modified by the kernel
itself on x86) is not modified at all, and the only thing that changes
is the virtual mapping of this memory, which is different between early
and late boot.

In the latter case, an entirely new allocation is created that carries a
new, updated version of the kernel's view of the EFI memory map. When
installing this new version, the old version will no longer be
referenced, and if the memory was allocated by the kernel, it will leak
unless it gets freed.

The logic that implements this freeing currently lives on the code path
that is shared between these two use cases, but it should only apply to
the latter. So move it to the correct spot.

While at it, drop the dummy definition for non-x86 architectures, as
that is no longer needed.

Cc: <stable@vger.kernel.org>
Fixes: f0ef6523475f ("efi: Fix efi_memmap_alloc() leaks")
Tested-by: Ashish Kalra <Ashish.Kalra@amd.com>
Link: https://lore.kernel.org/all/36ad5079-4326-45ed-85f6-928ff76483d3@amd.com
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 14:19:35 +01:00
..
libstub Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
test Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
apple-properties.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm-runtime.c efi: runtime: Fix potential overflow of soft-reserved region size 2024-11-18 22:25:34 +01:00
capsule-loader.c efi/capsule-loader: fix incorrect allocation size 2024-11-18 23:18:29 +01:00
capsule.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cper-arm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cper-x86.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dev-path-parser.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
earlycon.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efi-bgrt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efi-init.c efi: Don't add memblocks for soft-reserved memory 2024-11-18 22:25:34 +01:00
efi-pstore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efibc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efivars.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
embedded-firmware.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
esrt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fake_mem.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fake_mem.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fdtparams.c efi: xen: Set EFI_PARAVIRT for Xen dom0 boot on all architectures 2024-11-19 14:19:35 +01:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
memattr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
memmap.c efi/x86: Free EFI memory map only when installing a new one. 2024-11-19 14:19:35 +01:00
mokvar-table.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rci2-table.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
reboot.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
riscv-runtime.c efi: runtime: Fix potential overflow of soft-reserved region size 2024-11-18 22:25:34 +01:00
runtime-map.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
runtime-wrappers.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tpm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vars.c efivarfs: Request at most 512 bytes for variable names 2024-11-19 09:22:41 +01:00
x86_fake_mem.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00