linux/arch/x86/platform
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
..
atom x86/platform/atom: Check state of Punit managed devices on s2idle 2024-03-12 12:48:22 +02:00
ce4100 x86/of: Set the parse_smp_cfg for all the DeviceTree platforms by default 2024-04-03 08:46:08 +02:00
efi efi/x86: Free EFI memory map only when installing a new one. 2024-06-15 10:25:02 +02:00
geode x86/platform/geode: Convert alix LED to GPIO machine descriptor 2021-01-15 18:55:53 +01:00
intel x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
intel-mid x86/mpparse: Switch to new init callbacks 2024-02-15 22:07:41 +01:00
intel-quark arch/x86: Fix typos 2024-01-03 11:46:22 +01:00
iris x86/platform/iris: Convert to platform remove callback returning void 2024-04-10 14:59:30 +02:00
olpc x86/platform/olpc-xo1-sci: Convert to platform remove callback returning void 2024-04-10 14:59:31 +02:00
pvh xen: branch for v6.9-rc1 2024-03-19 08:48:09 -07:00
scx200 treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
ts5500 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
uv x86/cleanups changes for v6.8: 2024-01-08 17:23:32 -08:00
Makefile Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00