From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web11.321.1621354194443895099 for ; Tue, 18 May 2021 09:09:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.net header.s=2017 header.b=FAYihRhE; spf=pass (domain: posteo.net, ip: 185.67.36.66, mailfrom: sergei@posteo.net) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id C425B240102 for ; Tue, 18 May 2021 18:09:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1621354192; bh=zuntTj+pCBBstt3vir64UpYwHKTabIaeNjs7m6yZtxQ=; h=From:To:Cc:Subject:Date:From; b=FAYihRhE3Zatnz8dHQwzBowAsNr5SdIBQd9c8ZSzHrrfGmmu9igECnUxS3AEz9pIF hIvtgJXdXgW/773dRmri5TGQ/Mj+g7hrn6h679OfRqqbcWg1Cbyrnh+rXqpMCPhMzw 1y3geeniGsK7R7kn5k0eGVPz2I5nJjpbTtN3kNkwwxWQZamH0jeDrHzkwlVVMMs9Sn IKldkjzT4urcDp7lEXkqMRtC/w8LFnugmWV/cvN56+Hc0Qi2U6dxMZnaN720tHE3T8 S//FK9C27reIxZDuy/KlhrUNawx2bAl3oD9hp0aoCgucAoSqyt0t+2GCNcCqMuDUDb 2AgydloGl7sKg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Fl1DJ0zv6z9rxP; Tue, 18 May 2021 18:09:52 +0200 (CEST) From: "Sergei Dmitrouk" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni Subject: [PATCH v2 2/3] MdeModulePkg/PciBusDxe: Fix possible uninitialized use Date: Tue, 18 May 2021 16:09:41 +0000 Message-Id: <20210518160942.17634-3-sergei@posteo.net> In-Reply-To: <20210518160942.17634-1-sergei@posteo.net> References: <20210518160942.17634-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 --- Notes: v2: - simplify if-statement to avoid unused branches MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c index 6bba28367165..4caac56f1dcd 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -1778,10 +1778,9 @@ PciProgramResizableBar ( if (ResizableBarOp == PciResizableBarMax) { Bit = HighBitSet64(Capabilities); - } else if (ResizableBarOp == PciResizableBarMin) { + } else { + ASSERT (ResizableBarOp == PciResizableBarMin); Bit = LowBitSet64(Capabilities); - } else { - ASSERT ((ResizableBarOp == PciResizableBarMax) || (ResizableBarOp == PciResizableBarMin)); } ASSERT (Bit >= 0); -- 2.17.6