From nobody Sun Feb 8 06:56:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109104+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109104+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695794775; cv=none; d=zohomail.com; s=zohoarc; b=IFnADV2VyIPvAQT38n6byvXmwsRIvjuwjkD5LqtNyhgsVUj3qEv/61qSjpg09lQXBtMwXUCzUn3eSH0UJuWjnBuLT63IzLpE1oC1u4b9uajqwOSdebdqok1J0HTeijlCatvMd/ZoXyBlvBh+shL0wIwjdzIa4kkXBjlE4cyDyLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695794775; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=G7HzzoE2WRuISDIn8VbTj/EIqyhGc6053KV4cM0kaKQ=; b=dAQTxmeKTaDo8v7iwCJXStk6KpKRkFLvdyPYZ+B/L62Z51ik/SyD4cVOLX3HWv3Z8rG9NnDFsSXzp1QPUUsMwzMIOOVlRxMsOaB5VNfYYzg4az55NaNs3ODiPr09EgzDKPYVY0ZRhCooO/M0Zgm3SzYj7H9bjBe4V2cQzf0Fpbk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109104+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695794775939209.4762592449788; Tue, 26 Sep 2023 23:06:15 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=xq7x4pg4JRDqoYeqiZbD9PFaWVdSlafyU3IdfJeuIwE=; c=relaxed/simple; d=groups.io; h=From:To:Cc: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=1695794775; v=1; b=QMdwq+l6d1yWb3KiRhOUHMJgxkX1n8tFg0eRSOyT+/44/vfFxvFAXpP43ioA8LbfqtJI3vuu 6DsbEMG8AxnF+8AJizJLdmrqsCg1nDvGYW02nHjxCwVzn0NzG1m7mHCIX6OzFnZUo9TWALZ0kl9 3WqS3UyFU70H7LzycgUj0pfM= X-Received: by 127.0.0.2 with SMTP id j4ceYY1788612xUv3EmRf6dw; Tue, 26 Sep 2023 23:06:15 -0700 X-Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by mx.groups.io with SMTP id smtpd.web11.11802.1695794774952190888 for ; Tue, 26 Sep 2023 23:06:15 -0700 X-Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-79faf4210b2so260241939f.2 for ; Tue, 26 Sep 2023 23:06:14 -0700 (PDT) X-Gm-Message-State: qoteqvxEpOlBPf0NerHTZrr4x1787277AA= X-Google-Smtp-Source: AGHT+IEJlGPl7j1VNoGhI1HSPR0OE99SnuJFya0R53u5LNqGWFD37soMRH534dG0xh12OMqb/9GLQQ== X-Received: by 2002:a92:c5cd:0:b0:349:77c7:2ab6 with SMTP id s13-20020a92c5cd000000b0034977c72ab6mr1148907ilt.2.1695794774121; Tue, 26 Sep 2023 23:06:14 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:13 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue Date: Wed, 27 Sep 2023 11:35:59 +0530 Message-Id: <20230927060601.443693-4-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-1-rsingh@ventanamicro.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,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695794777939100003 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh In the function PromoteGuardedFreePages(), the value of AvailablePages cannot be ZERO at the condition check point if (AvailablePages !=3D 0) { as the code can come out of the while loop above only when AvailablePages is non-ZERO. Hence, remove the redundant condition check and the return FALSE; DEADCODE statement at the end of the function. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 35 +++++++++----------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/= Mem/HeapGuard.c index 0c0ca61872b4..016791ee002b 100644 --- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c +++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c @@ -1568,28 +1568,25 @@ PromoteGuardedFreePages ( } } =20 - if (AvailablePages !=3D 0) { - DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Av= ailablePages)); - ClearGuardedMemoryBits (Start, AvailablePages); + DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Avai= lablePages)); + ClearGuardedMemoryBits (Start, AvailablePages); =20 - if (gCpu !=3D NULL) { - // - // Set flag to make sure allocating memory without GUARD for page ta= ble - // operation; otherwise infinite loops could be caused. - // - mOnGuarding =3D TRUE; - Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO= _SIZE (AvailablePages), 0); - ASSERT_EFI_ERROR (Status); - mOnGuarding =3D FALSE; - } - - mLastPromotedPage =3D Start; - *StartAddress =3D Start; - *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1; - return TRUE; + if (gCpu !=3D NULL) { + // + // Set flag to make sure allocating memory without GUARD for page table + // operation; otherwise infinite loops could be caused. + // + mOnGuarding =3D TRUE; + Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO_S= IZE (AvailablePages), 0); + ASSERT_EFI_ERROR (Status); + mOnGuarding =3D FALSE; } =20 - return FALSE; + mLastPromotedPage =3D Start; + *StartAddress =3D Start; + *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1; + + return TRUE; } =20 /** --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109104): https://edk2.groups.io/g/devel/message/109104 Mute This Topic: https://groups.io/mt/101612679/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-