From nobody Sun Feb 8 12:38:41 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+109110+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+109110+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695795436; cv=none; d=zohomail.com; s=zohoarc; b=MceqtwHATPZTpRFhvpyaaePvcUYLfwAq8rrxNyQY9L/+1iNZ5TJyFtZ6d1MhFOI5twSGQ4BWL9ZzJ8gHLTx8LArAVJoQ+0v3xBN6hFFXHX3Z3sK5PdGqDqjFyOdk9PZ/O+C5LBFhkW+n41F/n7Thz7Zua3QiIPw/aCQX1Svg+b8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695795436; 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=5LrCwOZnoq6lcAI2H+KShpUAHKo3eW8e8ME5nr+PGms=; b=YBTTuwbuakUcviZsPaZ98+PeLVDwZ2yTsppNgZo36laX/qVw/7etxTvEdaUFaZ3mCSFncU+LYZp8IpIt1aXf6je1GVzP/JcDjUJDVLTWpSdagCpxznQUj2hCwhHFGxdwF7MXL+IoWc0xFCjr+rj6ZlCPR/czYfa/3310xTDnQZU= 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+109110+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169579543590141.17965849344387; Tue, 26 Sep 2023 23:17:15 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=l/d+UepkDdeJOOGatSy1I6f8S9zZjYikZXPpoeBYjd4=; 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=1695795435; v=1; b=mHJFutdfXNAHR7r4MsBX4JRV+2/ApW3vOWzrdrTefFPNSwG7pTUuKWuLWHYFf0R0+TV1DbjI dKFPStPYOwl+GTwMs49npZJPllNoOcPh+df5LrQbVbQcfvD3RBKiu5nGBoPQnlh9m3zzE3pcKqB rfphY9VSw1MWZCnWGSFBPvVo= X-Received: by 127.0.0.2 with SMTP id CFJ1YY1788612xOJ6NSkJ6qD; Tue, 26 Sep 2023 23:17:15 -0700 X-Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by mx.groups.io with SMTP id smtpd.web11.11919.1695795434958660080 for ; Tue, 26 Sep 2023 23:17:15 -0700 X-Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-79f989480e0so326553339f.3 for ; Tue, 26 Sep 2023 23:17:14 -0700 (PDT) X-Gm-Message-State: SQBR3hCeqgJyOWXnXyYNvEcCx1787277AA= X-Google-Smtp-Source: AGHT+IGEQahJ3ZlAC0xy7CQUR4xZpj/p1cvY5pTmsHUE+K7hyutBZEiX0OsAIS24nSgRwKPxmafmUQ== X-Received: by 2002:a6b:5b1a:0:b0:787:1472:3181 with SMTP id v26-20020a6b5b1a000000b0078714723181mr1274147ioh.3.1695795434012; Tue, 26 Sep 2023 23:17:14 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:17:13 -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 3/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix ARRAY_VS_SINGLETON Coverity issues Date: Wed, 27 Sep 2023 11:46:59 +0530 Message-Id: <20230927061701.451202-4-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-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695795436966100001 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The function PciHostBridgeResourceAllocator is not making use of the generic approach as is used in one of the other function namely - DumpResourceMap. As a result, the following warnings can be seen as reported by Coverity e.g. (30) Event address_of: Taking address with "&IoBridge" yields a singleton pointer. (31) Event callee_ptr_arith: Passing "&IoBridge" to function "FindResourceNode" which uses it as an array. This might corrupt or misinterpret adjacent memory locations. Hence, adopt the generic approach to fix the issues at relevant points. 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/PciLib.c | 37 ++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci= /PciBusDxe/PciLib.c index 84fc0161a19c..71767d3793d4 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -485,6 +485,8 @@ PciHostBridgeResourceAllocator ( UINT64 Mem64ResStatus; UINT64 PMem64ResStatus; UINT32 MaxOptionRomSize; + PCI_RESOURCE_NODE **ChildResources; + UINTN ChildResourceCount; PCI_RESOURCE_NODE *IoBridge; PCI_RESOURCE_NODE *Mem32Bridge; PCI_RESOURCE_NODE *PMem32Bridge; @@ -895,16 +897,39 @@ PciHostBridgeResourceAllocator ( // Create the entire system resource map from the information collecte= d by // enumerator. Several resource tree was created // - FindResourceNode (RootBridgeDev, &IoPool, &IoBridge); - FindResourceNode (RootBridgeDev, &Mem32Pool, &Mem32Bridge); - FindResourceNode (RootBridgeDev, &PMem32Pool, &PMem32Bridge); - FindResourceNode (RootBridgeDev, &Mem64Pool, &Mem64Bridge); - FindResourceNode (RootBridgeDev, &PMem64Pool, &PMem64Bridge); - + ChildResourceCount =3D FindResourceNode (RootBridgeDev, &IoPool, NULL); + ChildResources =3D AllocatePool (sizeof (PCI_RESOURCE_NODE *) * ChildR= esourceCount); + ASSERT (ChildResources !=3D NULL); + FindResourceNode (RootBridgeDev, &IoPool, &ChildResources[0]); + IoBridge =3D ChildResources[0]; ASSERT (IoBridge !=3D NULL); + + ChildResourceCount =3D FindResourceNode (RootBridgeDev, &Mem32Pool, NU= LL); + ChildResources =3D AllocatePool (sizeof (PCI_RESOURCE_NODE *) * ChildR= esourceCount); + ASSERT (ChildResources !=3D NULL); + FindResourceNode (RootBridgeDev, &Mem32Pool, &ChildResources[0]); + Mem32Bridge =3D ChildResources[0]; ASSERT (Mem32Bridge !=3D NULL); + + ChildResourceCount =3D FindResourceNode (RootBridgeDev, &PMem32Pool, N= ULL); + ChildResources =3D AllocatePool (sizeof (PCI_RESOURCE_NODE *) * ChildR= esourceCount); + ASSERT (ChildResources !=3D NULL); + FindResourceNode (RootBridgeDev, &PMem32Pool, &ChildResources[0]); + PMem32Bridge =3D ChildResources[0]; ASSERT (PMem32Bridge !=3D NULL); + + ChildResourceCount =3D FindResourceNode (RootBridgeDev, &Mem64Pool, NU= LL); + ChildResources =3D AllocatePool (sizeof (PCI_RESOURCE_NODE *) * ChildR= esourceCount); + ASSERT (ChildResources !=3D NULL); + FindResourceNode (RootBridgeDev, &Mem64Pool, &ChildResources[0]); + Mem64Bridge =3D ChildResources[0]; ASSERT (Mem64Bridge !=3D NULL); + + ChildResourceCount =3D FindResourceNode (RootBridgeDev, &PMem64Pool, N= ULL); + ChildResources =3D AllocatePool (sizeof (PCI_RESOURCE_NODE *) * ChildR= esourceCount); + ASSERT (ChildResources !=3D NULL); + FindResourceNode (RootBridgeDev, &PMem64Pool, &ChildResources[0]); + PMem64Bridge =3D ChildResources[0]; ASSERT (PMem64Bridge !=3D NULL); =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 (#109110): https://edk2.groups.io/g/devel/message/109110 Mute This Topic: https://groups.io/mt/101612809/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-