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.web12.21462.1621268564064195341 for ; Mon, 17 May 2021 09:22:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.net header.s=2017 header.b=KRfZgEA1; 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 4358D240027 for ; Mon, 17 May 2021 18:22:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1621268561; bh=zuntTj+pCBBstt3vir64UpYwHKTabIaeNjs7m6yZtxQ=; h=Date:From:To:Cc:Subject:From; b=KRfZgEA1H8zsz41ZraQuFrS7FRSjw1/fGCXtng94YFgrFXKcFGB1f5NLQ090A/Gcl FRN0HZzDMR47kPIuOMESntdMPABIUTJ/sVGfUch0pRr/Ngf0hbbz+z7RHVgHBrWtLI JEWWbqt0dEOIGfY01B5plF9NWschczZLPHMlchWslO5pJ32UwqqXBc2vTvsxiQeMsS F6KFwkFPgJvPF7tKmb+GpE5c14/rKUs+NZlzHdUdG72KYD9+wt8OcG0JkQ2dde193P NAzgteeQ1Tq00kyN4GqoO2h22hQjRI2h+VHrlf5lAvPcJxfJYgE8pLkyEJIqPLbxr4 fMzp80yTPoVZQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FkPYX2RSJz9rxH; Mon, 17 May 2021 18:22:40 +0200 (CEST) Date: Mon, 17 May 2021 16:22:35 +0000 From: "Sergei Dmitrouk" To: devel@edk2.groups.io, ray.ni@intel.com Cc: "Wang, Jian J" , "Wu, Hao A" Subject: Re: [edk2-devel] [PATCH v1 2/3] MdeModulePkg/PciBusDxe: Fix possible uninitialized use Message-ID: <20210517162235.GA21151@zx-spectrum> References: <20210514121714.17312-1-sergei@posteo.net> <20210514121714.17312-3-sergei@posteo.net> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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