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 BF810D800C4 for ; Tue, 7 Nov 2023 06:20:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1bBH+NgB/l3/udPYM8/ous+Zr5GLnivVOtgopcCRTWo=; 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=1699338017; v=1; b=YIMvs4esdJzdduCdUnyvh3E78OclHOnosTbCo66NiB5qJrYnhfevDUhIv4NEvUr9wqky7oQ6 kLyQQH930Ctw4ecJb9b+8OiAgDZxuhM2BWU/Wfhp/0sfojB2Va/dX+q82T2tzG4WEauJ8anh181 ny70MwJrZ3Kjf0P+wwS5X2jQ= X-Received: by 127.0.0.2 with SMTP id 0ICQYY7687511xTTYZtonfnF; Mon, 06 Nov 2023 22:20:17 -0800 X-Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by mx.groups.io with SMTP id smtpd.web10.5037.1699338016823354103 for ; Mon, 06 Nov 2023 22:20:16 -0800 X-Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-7a67f447bf0so219729939f.2 for ; Mon, 06 Nov 2023 22:20:16 -0800 (PST) X-Gm-Message-State: PmqxS4udEmIXBVtvJOvkYq7Rx7686176AA= X-Google-Smtp-Source: AGHT+IGO7S25DIILRNtCyPIEjFGslFAX1tCsfns1PYHDhbn2R8VZU9N/2bgbN2VWSBaEFLQOCnGEzw== X-Received: by 2002:a05:6e02:16c6:b0:357:a14e:17cf with SMTP id 6-20020a056e0216c600b00357a14e17cfmr2592574ilx.19.1699338015821; Mon, 06 Nov 2023 22:20:15 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id cb11-20020a0566381b0b00b00463ff175405sm1875508jab.80.2023.11.06.22.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 22:20:15 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 4/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue Date: Tue, 7 Nov 2023 11:49:58 +0530 Message-Id: <20231107061959.113213-5-rsingh@ventanamicro.com> In-Reply-To: <20231107061959.113213-1-rsingh@ventanamicro.com> References: <20231107061959.113213-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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=YIMvs4es; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none From: Ranbir Singh The function StartPciDevices has a check ASSERT (RootBridge !=3D NULL); but this comes into play only in DEBUG mode. In Release mode, there is no handling if the RootBridge value is NULL and the code proceeds to unconditionally dereference "RootBridge" which will lead to CRASH. Hence, for safety add NULL pointer checks always and return EFI_NOT_READY if RootBridge value is NULL which is one of the return values as mentioned in the function description header. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4239 Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModuleP= kg/Bus/Pci/PciBusDxe/PciDeviceSupport.c index 581e9075ad41..3de80d98370e 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c @@ -772,7 +772,10 @@ StartPciDevices ( LIST_ENTRY *CurrentLink;=0D =0D RootBridge =3D GetRootBridgeByHandle (Controller);=0D - ASSERT (RootBridge !=3D NULL);=0D + if (RootBridge =3D=3D NULL) {=0D + return EFI_NOT_READY;=0D + }=0D +=0D ThisHostBridge =3D RootBridge->PciRootBridgeIo->ParentHandle;=0D =0D CurrentLink =3D mPciDevicePool.ForwardLink;=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110814): https://edk2.groups.io/g/devel/message/110814 Mute This Topic: https://groups.io/mt/102438320/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-