From nobody Sun May 19 01:15:09 2024 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+97920+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+97920+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1672817391; cv=none; d=zohomail.com; s=zohoarc; b=GsF7z+DJPbB42y7vi5D4dSap9YSBl2DiiUEGnt4/dhw4lFhh6V7N63PXWMpnoi6h51rAr+yN9/H4pRgZcp/+cwdqvam3iK9Q527Nl1iMoeCDJ2SiLrC0lExuiEb1jcGFCC2MsDYmJITUe+n0TnAztOz4DIhCR+2+6fWVRweSb/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672817391; h=Content-Type:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=5FTs1qstCC6LiWwDq8EoDZbWvRstemljbOeVGvzvYvY=; b=G/tdg2O/uJsB5gDoMWk2fYGdQB6ChWXpZCvNj9/A+J83cCbHQHdhFrYH2Wyr2JClBL334XBSclwdiQeg+XbIf4l8MebFWXdQM7bLR/GS5F8wu6tkL18YtUFw71t5k462Oy+e37qBbWGL1Ajsc6uzG0UJakvmwnFwD9dl0nFn5nc= 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+97920+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1672817391679461.54474276199596; Tue, 3 Jan 2023 23:29:51 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id kVenYY1788612xTwiA7f1mb5; Tue, 03 Jan 2023 23:29:51 -0800 Subject: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue To: devel@edk2.groups.io From: "Ranbir Singh via groups.io" X-Originating-Location: Bengaluru, Karnataka, IN (122.172.85.38) X-Originating-Platform: Windows Chrome 108 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Tue, 03 Jan 2023 23:29:50 -0800 Message-ID: Precedence: Bulk List-Unsubscribe: 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,Ranbir.Singh3@Dell.com X-Gm-Message-State: jzJ7jwjhmOJjfFbGAgJwR5ZFx1787277AA= Content-Type: multipart/alternative; boundary="FeSOwPpgtUyUKHztFIbw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1672817391; bh=W5JVRydH9CSSjoxMo28gCjHSUqEy6t1eB7Ni+XsYGeM=; h=Content-Type:Date:From:Reply-To:Subject:To; b=fHlPeYCtSLLYhR1UNu2FjQCLQnXveRdKq8xyAm3Ps4w+EwgvjVUWJPDhM8Yg2xpl6Vw UhBBVsGw4mNUqYQhmhFf9WibpJYr1EI3EkDjWUUyUFcKuNOVjqL5UZePhZClvfWCsqSUU jkmGdOvYrGCC5ANERFETOP9GCgn3kc6wF/8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1672817393805100002 --FeSOwPpgtUyUKHztFIbw Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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=3D4240 Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModuleP= kg/Bus/Pci/PciBusDxe/PciDeviceSupport.c index 581e9075ad..f43f10325f 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c @@ -773,6 +773,11 @@ StartPciDevices ( RootBridge =3D GetRootBridgeByHandle (Controller); ASSERT (RootBridge !=3D NULL); + +=C2=A0 if (RootBridge =3D=3D NULL) { +=C2=A0 =C2=A0 return EFI_NOT_READY; +=C2=A0 } + ThisHostBridge =3D RootBridge->PciRootBridgeIo->ParentHandle; CurrentLink =3D mPciDevicePool.ForwardLink; -- 2.36.1.windows.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 (#97920): https://edk2.groups.io/g/devel/message/97920 Mute This Topic: https://groups.io/mt/96046307/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- --FeSOwPpgtUyUKHztFIbw Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
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.<= /div>
 
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=3D4240
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 +++++
 1 file changed, 5 insertions(+)
 
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeMo= dulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index 581e9075ad..f43f10325f 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -773,6 +773,11 @@ StartPciDevices (
 
   RootBridge =3D GetRootBridgeByHandle (Controller);
   ASSERT (RootBridge !=3D NULL);
+
+  if (RootBridge =3D=3D NULL) {
+    return EFI_NOT_READY;
+  }
+
   ThisHostBridge =3D RootBridge->PciRootBridgeIo->Par= entHandle;
 
   CurrentLink =3D mPciDevicePool.ForwardLink;
--
2.36.1.windows.1
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

= View/Reply Online (#97920) | =20 | Mute = This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [importer@patchew.org]

_._,_._,_
--FeSOwPpgtUyUKHztFIbw--