linux/drivers/firmware
Ard Biesheuvel 75dde792d6 efi/x86: Free EFI memory map only when installing a new one.
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: f0ef652347 ("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>
2024-06-15 10:25:02 +02:00
..
arm_ffa soc: drivers for 6.10 2024-05-13 08:48:42 -07:00
arm_scmi virtio: features, fixes, cleanups 2024-05-23 12:04:36 -07:00
broadcom MIPS: BCM47XX: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:51 -07:00
cirrus ALSA: cirrus: Tidy up of firmware control read/write 2024-04-03 20:45:32 +01:00
efi efi/x86: Free EFI memory map only when installing a new one. 2024-06-15 10:25:02 +02:00
google firmware: google: cbmem: drop driver owner initialization 2024-04-03 15:09:26 +08:00
imx firmware: imx-dsp: Convert to platform remove callback returning void 2024-01-04 17:01:14 +01:00
meson firmware: meson-sm: unmap out_base shmem in error path 2023-11-27 09:17:51 +01:00
microchip firmware: microchip: clarify that sizes and addresses are in hex 2024-04-24 22:02:20 +01:00
psci firmware/psci: demote suspend-mode warning to info level 2023-04-14 13:48:56 +02:00
qcom soc: drivers for 6.10 2024-05-13 08:48:42 -07:00
smccc firmware: smccc: Export revision soc_id function 2024-04-19 12:34:27 +05:30
tegra firmware: tegra: bpmp: Return directly after a failed kzalloc() in get_filename() 2024-02-21 17:10:32 +01:00
xilinx firmware: xilinx: Add ZynqMP efuse access API 2024-03-07 20:21:53 +00:00
arm_scpi.c firmware: arm_scpi: Convert to platform remove callback returning void 2024-01-04 17:01:14 +01:00
arm_sdei.c arm64: sdei: abort running SDEI handlers during crash 2023-08-04 17:35:33 +01:00
dmi_scan.c Driver core changes for 6.10-rc1 2024-05-22 12:13:40 -07:00
dmi-id.c firmware: dmi-id: add a release callback function 2024-04-08 09:34:24 +02:00
dmi-sysfs.c firmware: dmi-sysfs: handle HAS_IOPORT=n 2023-05-31 19:17:29 +01:00
edd.c edd: make kobj_type structure constant 2023-03-09 18:07:33 +01:00
iscsi_ibft_find.c iscsi_ibft: Fix finding the iBFT under Xen Dom 0 2023-06-26 07:47:11 +02:00
iscsi_ibft.c
Kconfig video: Add helpers for decoding screen_info 2024-02-14 10:09:13 +01:00
Makefile Core: 2024-01-12 13:54:25 -08:00
memmap.c
mtk-adsp-ipc.c firmware: mtk-adsp-ipc: Convert to platform remove callback returning void 2024-01-04 17:01:14 +01:00
qemu_fw_cfg.c crash: split vmcoreinfo exporting code out from crash_core.c 2024-02-23 17:48:22 -08:00
raspberrypi.c firmware: raspberrypi: Use correct device for DMA mappings 2024-04-04 09:49:20 -07:00
stratix10-rsu.c firmware: stratix10-rsu: Convert to platform remove callback returning void 2024-01-04 17:01:15 +01:00
stratix10-svc.c firmware: stratix10-svc: Convert to platform remove callback returning void 2024-01-04 17:01:15 +01:00
sysfb_simplefb.c firmware/sysfb: Set firmware-framebuffer parent device 2024-02-14 10:09:17 +01:00
sysfb.c firmware/sysfb: fix an error code in sysfb_init() 2024-02-27 09:21:06 +01:00
ti_sci.c firmware: ti_sci: Unconditionally register reset handler 2024-04-09 11:05:10 -05:00
ti_sci.h
trusted_foundations.c
turris-mox-rwtm.c firmware: turris-mox-rwtm: Convert to platform remove callback returning void 2024-01-04 17:01:15 +01:00