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 <gaoliming@byosoft.com.cn>
Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Oliver Smith-Denny 2024-03-09 11:06:03 -08:00 committed by mergify[bot]
parent 019feb42a1
commit bf8f16f771
1 changed files with 6 additions and 1 deletions

View File

@ -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) ||