From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 6B7E5941B43 for ; Sat, 9 Mar 2024 19:06:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jkJdCaDvFQA1V4O0lNQ5LFrYYTo0SE602gRiIDlsB0M=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:From:To:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1710011164; v=1; b=Id6/soKwd/ZDRZqoax5sf/VqRqjFADGsXkQnvIFtvbjW43P8ZN9/zTv4ond1VMimHTqPFewH eoa1kJBldkgDgApr2IqbeGw+WgeZKBOJuCw0GUtPXTMTpFQOs+eo5XUhbuT3DDMskxACVqQ2bx4 d6X52g5awjTQSRe4jBC3MHSlZa6P72bLWGFH7aTS1E0dT6Au/72U6sMEPjSFmtAtN9IDzHT8yuo cx/KxGBHdcij9C7euubAhQV1vkzuTnO/kq4JJa32UmmiBnPjTei/MFmaL8/0NP7prQzarNFUTWx wgs54KOG9vczlIxLst/bg+RCGZTs5JFyrZq7hVCdXLRcA== X-Received: by 127.0.0.2 with SMTP id iG0DYY7687511xRxLiP47bst; Sat, 09 Mar 2024 11:06:04 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.19014.1710011163307522676 for ; Sat, 09 Mar 2024 11:06:03 -0800 X-Received: from OSD-Desktop.redmond.corp.microsoft.com (unknown [131.107.160.171]) by linux.microsoft.com (Postfix) with ESMTPSA id E2EDC20B74C1 for ; Sat, 9 Mar 2024 11:06:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E2EDC20B74C1 From: "Oliver Smith-Denny" 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 Message-Id: <20240309190559.28677-2-osde@linux.microsoft.com> In-Reply-To: <20240309190559.28677-1-osde@linux.microsoft.com> References: <20240309190559.28677-1-osde@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,osde@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: KPwXsfAKQMGCNpLWyFpGXOR8x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="Id6/soKw"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- 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; } =20 + if (Entry =3D=3D NULL) { + ASSERT (Entry !=3D NULL); + Status =3D EFI_NOT_FOUND; + goto Done; + } + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; =20 - ASSERT (Entry !=3D NULL); if ((Entry->Type =3D=3D EfiACPIReclaimMemory) || (Entry->Type =3D=3D EfiACPIMemoryNVS) || (Entry->Type =3D=3D EfiRuntimeServicesCode) || --=20 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] -=-=-=-=-=-=-=-=-=-=-=-