From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web08.7854.1620994651596367325 for ; Fri, 14 May 2021 05:17:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.net header.s=2017 header.b=d3uhxUEK; spf=pass (domain: posteo.net, ip: 185.67.36.65, mailfrom: sergei@posteo.net) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id DE2BA240028 for ; Fri, 14 May 2021 14:17:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1620994649; bh=9ngR4RojTsSO++DbD+mln6E6aYXR6JeJyz4HnYm1Yro=; h=From:To:Cc:Subject:Date:From; b=d3uhxUEKZ4rmf/N6Mdf1lavly1up6C6JS5RcVVHcSSW8CC75C01HcpcWrlYj8Ofko z7+oRMdwc5ey8ROeM87y4X8KNTMYNvgYZWP1OoFbRrXLsFEOtGWg4zG2/y6OAt7xkM f7NtBPVOgQ+ouxkYt6UeQjHIXrU9RRUc+tK1/MfqHmo+E99Pkzbh8RRJCDB2i4Gh4L C0VhgIPRAPB6ogjEHGMHzrGs4JpyohLlXM5gRCIkFWhXX5+wNaS7DqwPCem+OlW7kr 0K+DkbIBbiszZf9EpGyO+jfIJfwJ6OayGAO0kFSP9N8a0ZVvGzbPR69TJaKSXLAUL/ ar2zlGxV4shrA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FhSG06mB7z9rxb; Fri, 14 May 2021 14:17:28 +0200 (CEST) From: "Sergei Dmitrouk" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni Subject: [PATCH v1 2/3] MdeModulePkg/PciBusDxe: Fix possible uninitialized use Date: Fri, 14 May 2021 12:17:13 +0000 Message-Id: <20210514121714.17312-3-sergei@posteo.net> In-Reply-To: <20210514121714.17312-1-sergei@posteo.net> References: <20210514121714.17312-1-sergei@posteo.net> If the function gets invalid value for the `ResizableBarOp` parameter and asserts are disabled, `Bit` can be used uninitialized. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Sergei Dmitrouk --- MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c index 6bba28367165..de601713a53b 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -1781,6 +1781,11 @@ PciProgramResizableBar ( } else if (ResizableBarOp == PciResizableBarMin) { Bit = LowBitSet64(Capabilities); } else { + // + // Set Bit to avoid uninitialized use when built without assertions. + // + Bit = 0; + ASSERT ((ResizableBarOp == PciResizableBarMax) || (ResizableBarOp == PciResizableBarMin)); } -- 2.17.6