diff options
author | Oliver Smith-Denny <osde@linux.microsoft.com> | 2024-03-09 11:06:03 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-03-14 16:29:22 +0000 |
commit | bf8f16f771d48c7cb4c0dfa548d296972513efe2 (patch) | |
tree | 1877b158c882076dce640aa749e933118186ac35 | |
parent | 019feb42a1dd1136014b19df3fcb618861b621e3 (diff) | |
download | edk2-bf8f16f771d48c7cb4c0dfa548d296972513efe2.tar.gz edk2-bf8f16f771d48c7cb4c0dfa548d296972513efe2.tar.bz2 edk2-bf8f16f771d48c7cb4c0dfa548d296972513efe2.zip |
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>
-rw-r--r-- | MdeModulePkg/Core/Dxe/Mem/Page.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 3205732ede..dd558696ba 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) ||
|