edk2/MdeModulePkg/Core
Piotr Wejman 66346d5ede MdeModulePkg: Fix FreePages not existent memory
Commit 2d69507a4d added an attribute check to
prevent freeing memory that is read-only, read-protected, or for which
attribute retrieval fails. In such cases the code returned EFI_SUCCESS and
leaked the memory.

This introduced a regression in the System Architecture Compliance Suite
(ACS) BS.FreePages – Not Existent Memory test.
Link: https://github.com/tianocore/edk2-test/blob/edk2-test-stable202509/uefi-sct/Doc/TestCaseSpec/03_Services_Boot_Services.md#freepages
Test number: 5.1.2.2.1

GetMemoryAttributes() returns EFI_UNSUPPORTED for memory regions outside
system memory. The previous change treated all errors as a reason to leak
memory, while only the EFI_NO_MAPPING error code should trigger that
behavior. As a result, freeing non-existent memory incorrectly returned
EFI_SUCCESS instead of EFI_NOT_FOUND.

To fix this, memory is now leaked only when:
- GetMemoryAttributes() returns EFI_NO_MAPPING (inconsistent attributes),
  or
- GetMemoryAttributes() succeeds and the pages are marked RO or RP.

All other errors fall through to CoreInternalFreePages(), restoring the
previous and correct behavior.

Signed-off-by: Piotr Wejman <piotr.wejman@arm.com>
2025-12-30 01:36:38 +00:00
..
Dxe MdeModulePkg: Fix FreePages not existent memory 2025-12-30 01:36:38 +00:00
DxeIplPeim MdeModulePkg: Fix missing NULL tests. 2025-11-22 18:58:47 +00:00
Pei MdeModulePkg: Remove ambiguous negation of narrower type 2025-12-03 11:50:28 +01:00
PiSmmCore MdeModulePkg: Fix recently introduced uninitialized variable usage. 2025-12-02 11:22:46 +01:00
RuntimeDxe MdeModulePkg: Align RuntimeDxe function headers with UEFI return values 2024-02-09 22:16:32 +00:00