From bf8f16f771d48c7cb4c0dfa548d296972513efe2 Mon Sep 17 00:00:00 2001 From: Oliver Smith-Denny Date: Sat, 9 Mar 2024 11:06:03 -0800 Subject: MdeModulePkg: DxeCore: Fix CodeQL Error in FreePages CodeQL flags the Free Pages logic for not ensuring that Entry is non-null before using it. Add a check for this and appropriately bail out if we hit this case. Cc: Liming Gao Signed-off-by: Oliver Smith-Denny Reviewed-by: Liming Gao --- MdeModulePkg/Core/Dxe/Mem/Page.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 3205732..dd55869 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1658,9 +1658,14 @@ CoreInternalFreePages ( goto Done; } + if (Entry == NULL) { + ASSERT (Entry != NULL); + Status = EFI_NOT_FOUND; + goto Done; + } + Alignment = DEFAULT_PAGE_ALLOCATION_GRANULARITY; - ASSERT (Entry != NULL); if ((Entry->Type == EfiACPIReclaimMemory) || (Entry->Type == EfiACPIMemoryNVS) || (Entry->Type == EfiRuntimeServicesCode) || -- cgit v1.1