From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.13583.1621217144763832932 for ; Sun, 16 May 2021 19:05:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=qu2zllK6; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: ray.ni@intel.com) IronPort-SDR: /cKWcULfk1Cu1kLj/lRbfX+vuv18EXwnRb3OyexOUbLZjdepdPzuiCN1DplIk5lS0TTEdyl4NY OIen585udPpQ== X-IronPort-AV: E=McAfee;i="6200,9189,9986"; a="200420259" X-IronPort-AV: E=Sophos;i="5.82,306,1613462400"; d="scan'208";a="200420259" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2021 19:05:42 -0700 IronPort-SDR: nRAL6gEiqhhi0SvL8aREQY76jNGO2saHXfxgL5F6abz/0skMDXpzwgC+nDLUU1HuM1tsWJCtEb fY1X2PLHz/VQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,306,1613462400"; d="scan'208";a="393332979" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga003.jf.intel.com with ESMTP; 16 May 2021 19:05:42 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Sun, 16 May 2021 19:05:41 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Sun, 16 May 2021 19:05:41 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.174) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Sun, 16 May 2021 19:05:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=df/9iCqM+ojj3h0g7zaXo2k9TnuXd+p3+md+D6e8o/3tYz/ljdimhDnSKyruPIJbvvNvv4373Uff6APwfa/Oidb/oR2oWDT2uqEbrirpHBQ6sGTx6Gna9YevS4SJTN4sbsnrYSjPIzkTEbpjDjbMjOvfNHaZBNZWiw4F4heVesZNURMqCKEXVyx2cSEaDCiSkfudefPiAvzY6UpNoHC99K0zhW6cSrU8vVbmSSsI9VGjXHP9PycWj1zePCccv2hOzgEBlnsUyohuYA4tLUBuFs+i6TegysiG9I8ayd3d4JRRBBaQGXjgD5zkAOa4XPh5iAmlII9mFuGkTbCuYyBTLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u5RaXt6jnfbe51Yj9P2eq9+MFbl0grswS6wxgjXYS+E=; b=OHZBgum3kD73pmn0IqjeaQCj0IdmszfYq8EZAQ9fWNbnV5T8snYufTe0gNQnfVJQTOoPtz6y93Nr/ApQAEN+Z99vRBQhTn3pspwzTXyu8H/L9K06XFV6No3nQpw4+uvoVlZAn4l2s54eer39jJe3wOKFmZZvNHriX1nERCOIzv3QA0nCLB01aVfLjjC8+o3j4qpe7n7wVOmaOVvZrgeyAj+0TZoGCP19MiMg29i3au+ivtWJdhvZr5HB1r2a76LvawLPRXUL8d13UUg1WgoljnlKy6+4TnlJxZ3/+gkwlwKMYPDUScGTbK9uGAvWKVVkB+Q4GxNfIpXgew9i0FBtFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u5RaXt6jnfbe51Yj9P2eq9+MFbl0grswS6wxgjXYS+E=; b=qu2zllK64iazgjClRe8sWzQCt+n4xOPPwmACQPzC0lteR2bwaVMH9C+7FY1bnuIoLCdtJSPgpBb3towwl3+AS3WFwrvQTp5tl1R+eNX3ut9PE+iXrNuSRn9tMLddxrCVRTtlEKUBgqCm+8TgvjQybS70fEWZvIpx2xjHGynMwKI= Received: from CO1PR11MB4930.namprd11.prod.outlook.com (2603:10b6:303:9b::11) by MWHPR11MB1822.namprd11.prod.outlook.com (2603:10b6:300:111::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Mon, 17 May 2021 02:05:39 +0000 Received: from CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::59d6:8b94:55bf:36e7]) by CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::59d6:8b94:55bf:36e7%5]) with mapi id 15.20.4129.031; Mon, 17 May 2021 02:05:39 +0000 From: "Ni, Ray" To: Sergei Dmitrouk , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Wu, Hao A" Subject: Re: [PATCH v1 2/3] MdeModulePkg/PciBusDxe: Fix possible uninitialized use Thread-Topic: [PATCH v1 2/3] MdeModulePkg/PciBusDxe: Fix possible uninitialized use Thread-Index: AQHXSLsryRNhAX6iC0ykOfpmdKzaWKrm8HGA Date: Mon, 17 May 2021 02:05:39 +0000 Message-ID: References: <20210514121714.17312-1-sergei@posteo.net> <20210514121714.17312-3-sergei@posteo.net> In-Reply-To: <20210514121714.17312-3-sergei@posteo.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: posteo.net; dkim=none (message not signed) header.d=none;posteo.net; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.194] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0e61996b-3ce5-4b47-a968-08d918d84505 x-ms-traffictypediagnostic: MWHPR11MB1822: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 950MZcdsSr3Wfnkuy2aDPFlbxPmtgugog9Uf0atE2e7JWu5crSUOyUbzxrOEY91+AawQmgzCJU0MTM/iYrxc/Sz+LViX0rQ8PnLzVLNexufDFmfFr+Nckz+iWjrgpzO5drHdFvmhkrsm+KDbKQKGvnktoCNvOFhY1b5tpfX1O4hQ7Lzg19MbBxhIMiCCmmfnEjXVLgjDNEP6tdT4q0WvH23k+JWisRblM3NIET4y6jE8Er3cwGQFuso+/1hW+nTnbdUJVfdgwrTG+kvuw3dRyWLU0EoV4ydD2wPHO110HWgWL+GqJfmvyFMtt6IRm5jLAtpM4arn6vgfV4iDf4RiS3jmFTNPXPGo4xTWDrMZrs/a2ibmfqz5PLXsWf4pRSi7qD0Ih1CVAcQjpUAnTXwXkyWbkn2q/1nt3iBaL5U/8Nlb4VKffRgci5kEVQCz4WFOVWOGyOI8PzjBsXPDkuYVhVHU5Udv5QSpK1xzrz8KMsV2sf7NG6N5krR0UBjA+GEeiXov18I8XERBW+SPlCBO1WlF+0ydX2+KqU4ikIeezzFpKBsmjahGmBaUyhQTdY7VxqSh5vqF4jhOIpg/EkJB2i3RIt1tTKMrzxkVlKgyaxo= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4930.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(366004)(396003)(136003)(346002)(39860400002)(2906002)(38100700002)(122000001)(110136005)(316002)(478600001)(186003)(86362001)(55016002)(54906003)(53546011)(83380400001)(7696005)(107886003)(8936002)(8676002)(9686003)(64756008)(66446008)(66556008)(66476007)(66946007)(52536014)(71200400001)(76116006)(4326008)(6506007)(26005)(33656002)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?f1lKxbeHogDB4Hp4F8jGz4ewvT3vvZLEdRkz3c2CESeRpreZN+V3zCoXAB4t?= =?us-ascii?Q?fUQcULAPS9XG7ZLBbcUyXWDrK0vn3WR/8L5Twnopem2Q4ZSKGu7aGyPdoJXT?= =?us-ascii?Q?ZfXTi2bqSZH3K1CM3M0t7o1c/xi4rxSRGEFXtkB0tTyFR4Pjd4mjseaiCTFQ?= =?us-ascii?Q?lHjIpdvmkWxKtQFSPWM4s5js2KxSQ5jz/REhAMACkm7Wrv4lZ9qzaiGiQYjP?= =?us-ascii?Q?+J9I0T9AllzC8uRsPFFWZA4PFDCWa3aQFlFHJvYuYdvga/72CTzMJy/MCCnz?= =?us-ascii?Q?AxdFhnYlm/0i8CDeu9MWcjsknJ4eyJcFKL7EkAtRi0tc9Kfuuh4Tb75d+PXK?= =?us-ascii?Q?yaSZvuQ9bcY60psPDN0zbbYk9H2wlGqsQp6QTcDasWxCXQzDhHWHXwyXClkD?= =?us-ascii?Q?pvhz9Ud8MXhUeJIs8pJ53K09gMIN/1O9S9lCDJadpTjWjR9xtRl8lrG/g1Ne?= =?us-ascii?Q?4bEZLv5zXsS+xAckEaIxIWTCSiJDkjRwryxw+ChgfcrzTpPzWmhfypNEl1bS?= =?us-ascii?Q?sYXmuRFgviVELUVZLM2byIVEG3NSrXUjQcBfk3wfr+74xEGwkY6miXmvf5vf?= =?us-ascii?Q?M9M9vDXM9lWEdEN9zWxsPcmcLuYPrnKQb9/DqankucCNZNQWfptCa8lTc6Ty?= =?us-ascii?Q?TL1IW+wK60hZzqsIJ8qYQOdfN/ATdnOciPx7acahmQP/mOu0+Xb1tgSI1eyn?= =?us-ascii?Q?T8OjJ4bPucGq5BwlwE/MB4ox8FjPOy6AYU2aVKMqmqx25ZowaIVD5MijWI5a?= =?us-ascii?Q?Beve61mSCOtQSLEigRNmvWLcsG3vhc5xEr6uNZaM2m7OEHMjx+2fcp1M85k6?= =?us-ascii?Q?k2vg+Rm0790ZEg5LzaucRRouEtXjzgdSIphYbQP0PjOkGGkmBR60xd7NUIfQ?= =?us-ascii?Q?8ZV64UCzKN7dsTxEq/sSRIAKgBwBxFwqF2he8ULGI1U0lneW5ShmHS0TQxCt?= =?us-ascii?Q?SrE6zbaoZahiL6i/OTCAZXx2FsqdHlMBEOi/MjlJ8iaBB469Els4VeCPS74u?= =?us-ascii?Q?cWRjq1DlS3WVnmfLjnyHMGymiyETRN68Bs0aanCcHp7ghIfkGBtHgLpaEB93?= =?us-ascii?Q?qrT1mGEsLC3Li2mZ4/wXdTPUQFo7QfpQKibCHXsaFz52Z6g8sBs9jtB140a0?= =?us-ascii?Q?Fk3ky87PKUrzk1y+GV5qy37jFp6MlnC78wpoVTRNG/jlvaRQevjEwvV1fK6l?= =?us-ascii?Q?/Pw7LOE0QYc0+mrkIat9frU+G8dY8DsyFyQqz5ZdfrqCO8g/uZsQUsFztElY?= =?us-ascii?Q?3WQZaId7rok/8N8Z9FPZuBIY1Q0acDroKerfpYrRVvuDSCXEVlC1CI2wf4Kk?= =?us-ascii?Q?piGQBifg88cR45HPZd33o6Wm?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4930.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e61996b-3ce5-4b47-a968-08d918d84505 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2021 02:05:39.7695 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iXuRjcHalTrddduWn3lHNKV7JNWPMvCVQ1Ydx+fGu2VEhLXv1RtVGFReLvOxEtb0k0Af1IUp1JW1/PHRe2j8Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1822 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable How about below fix? I think it might be simpler to understand and doesn't = introduce unnecessary logic to handle impossible case: if (ResizableBarOp =3D=3D PciResizableBarMax) { Bit =3D HighBitSet64(Capabilities); } else { ASSERT (ResizableBarOp =3D=3D PciResizableBarMin); Bit =3D LowBitSet64(Capabilities); } > -----Original Message----- > From: Sergei Dmitrouk > Sent: Friday, May 14, 2021 8:17 PM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A ; > Ni, Ray > Subject: [PATCH v1 2/3] MdeModulePkg/PciBusDxe: Fix possible uninitialize= d > use >=20 > If the function gets invalid value for the `ResizableBarOp` parameter > and asserts are disabled, `Bit` can be used uninitialized. >=20 > 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(+) >=20 > 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 =3D=3D PciResizableBarMin) { > Bit =3D LowBitSet64(Capabilities); > } else { > + // > + // Set Bit to avoid uninitialized use when built without assertion= s. > + // > + Bit =3D 0; > + > ASSERT ((ResizableBarOp =3D=3D PciResizableBarMax) || (ResizableBa= rOp =3D=3D > PciResizableBarMin)); > } >=20 > -- > 2.17.6