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 6CE87AC0C8E for ; Wed, 27 Sep 2023 06:17:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=SXcAUhC2e6LX0zVigocN0+JtneusDGe+6WjBiA6uz3A=; 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=1695795438; v=1; b=CrcYFgxZhBLhH15bGVL9Qd6O7X+Y/CTbP2OUdFNeccTSEDCbVf1+LaqhhI5Gi8lck1qcVMUy 12HshBvZzAa6uZ9K0Z3vSdT9vrV44vgLrFykwSsKQSuGqzSz9LAgPjiWuzlhYzgpVNldNyN+375 kRE8FH+Xpis2Ofl45j6Z7AkE= X-Received: by 127.0.0.2 with SMTP id qtAPYY7687511x2qB91WyT9G; Tue, 26 Sep 2023 23:17:18 -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.web10.11692.1695795437434332916 for ; Tue, 26 Sep 2023 23:17:17 -0700 X-Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-79f915e5b47so356663139f.2 for ; Tue, 26 Sep 2023 23:17:17 -0700 (PDT) X-Gm-Message-State: DxUqProbkrMKnTwLOLwFerx4x7686176AA= X-Google-Smtp-Source: AGHT+IELsGBLrm9faq0hp4PTw25pMs+bgQwqy6+GBNlDPjUnPWhiJPfT9ZON1McfemuraV7OOnyMDA== X-Received: by 2002:a6b:dd07:0:b0:790:fa58:69d2 with SMTP id f7-20020a6bdd07000000b00790fa5869d2mr1008146ioc.20.1695795436530; Tue, 26 Sep 2023 23:17:16 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id o23-20020a6b5a17000000b007836c7e8dccsm2571625iob.17.2023.09.26.23.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:17:16 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 4/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue Date: Wed, 27 Sep 2023 11:47:00 +0530 Message-Id: <20230927061701.451202-5-rsingh@ventanamicro.com> In-Reply-To: <20230927061701.451202-1-rsingh@ventanamicro.com> References: <20230927061701.451202-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=CrcYFgxZ; dmarc=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 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: Hao A Wu 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, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModuleP= kg/Bus/Pci/PciBusDxe/PciDeviceSupport.c index 581e9075ad41..f43f10325f16 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c @@ -773,6 +773,11 @@ StartPciDevices ( =0D RootBridge =3D GetRootBridgeByHandle (Controller);=0D ASSERT (RootBridge !=3D NULL);=0D +=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 (#109111): https://edk2.groups.io/g/devel/message/109111 Mute This Topic: https://groups.io/mt/101612810/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-