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 B5AB47803CD for ; Sat, 17 Feb 2024 01:27:32 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jQA530JIV17CmOFgsQY4n80aygzI+H0Wv9+wvn28w0Q=; 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=20140610; t=1708133251; v=1; b=kcyv2NLRL/3GuP8niCKoNneBtdIRZhi36uVPYkio8pyqcKv87Pm6TKUt/CWg+JEKdWE8Zowp h/6oWhC+mtHbbhhsCFgdhZN3UYDX/BlGvLc/94XneEbgLjKu12FMmbllwNlkZKywLaSnLVarVg4 Slv12twUzlWIvI/kQoqSd04g= X-Received: by 127.0.0.2 with SMTP id Bow6YY7687511xoR8FkGJqGH; Fri, 16 Feb 2024 17:27:31 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.1853.1708133250408693594 for ; Fri, 16 Feb 2024 17:27:30 -0800 X-Received: from OSD-Desktop.redmond.corp.microsoft.com (unknown [131.107.160.171]) by linux.microsoft.com (Postfix) with ESMTPSA id F0989207FD3D for ; Fri, 16 Feb 2024 17:27:29 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F0989207FD3D From: "Oliver Smith-Denny" To: devel@edk2.groups.io Subject: [edk2-devel][PATCH v2 1/3] MdeModulePkg: DxeCore: Fix CodeQL Error in FreePages Date: Fri, 16 Feb 2024 17:27:23 -0800 Message-Id: <20240217012725.31763-2-osde@linux.microsoft.com> In-Reply-To: <20240217012725.31763-1-osde@linux.microsoft.com> References: <20240217012725.31763-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: JqA6B7nz4KQKlbaVBwVGpEfRx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=kcyv2NLR; 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 (#115561): https://edk2.groups.io/g/devel/message/115561 Mute This Topic: https://groups.io/mt/104405580/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-