From: "Oliver Smith-Denny" <osde@linux.microsoft.com>
To: devel@edk2.groups.io
Subject: [edk2-devel][PATCH v3 1/3] MdeModulePkg: DxeCore: Fix CodeQL Error in FreePages
Date: Sat, 09 Mar 2024 11:06:03 -0800 [thread overview]
Message-ID: <20240309190559.28677-2-osde@linux.microsoft.com> (raw)
In-Reply-To: <20240309190559.28677-1-osde@linux.microsoft.com>
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.
Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
---
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 3205732ede17..dd558696ba59 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) ||
--
2.40.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116558): https://edk2.groups.io/g/devel/message/116558
Mute This Topic: https://groups.io/mt/104832604/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-03-09 19:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-09 19:06 [edk2-devel][PATCH v3 0/3] Fix Runtime Granularity Issues Oliver Smith-Denny
2024-03-09 19:06 ` [edk2-devel][PATCH v3 3/3] MdeModulePkg: DxeCore: Do Not Apply Guards to Unsupported Types Oliver Smith-Denny
2024-03-11 14:01 ` Ard Biesheuvel
2024-03-09 19:06 ` [edk2-devel][PATCH v3 2/3] MdeModulePkg: DxeCore: Correct Runtime Granularity Memory Type Oliver Smith-Denny
2024-03-09 19:06 ` Oliver Smith-Denny [this message]
2024-03-14 14:52 ` 回复: [edk2-devel][PATCH v3 0/3] Fix Runtime Granularity Issues gaoliming via groups.io
2024-03-14 16:31 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240309190559.28677-2-osde@linux.microsoft.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox