From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A1F0421CFA60E for ; Wed, 16 Aug 2017 14:24:53 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Aug 2017 14:27:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,384,1498546800"; d="scan'208";a="1163366753" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by orsmga001.jf.intel.com with ESMTP; 16 Aug 2017 14:27:19 -0700 Received: from orsmsx154.amr.corp.intel.com (10.22.226.12) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 16 Aug 2017 14:27:19 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.211]) by ORSMSX154.amr.corp.intel.com ([169.254.11.246]) with mapi id 14.03.0319.002; Wed, 16 Aug 2017 14:27:18 -0700 From: "Kinney, Michael D" To: "Dong, Eric" , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "Ni, Ruiyu" , "Shao, Ming" Thread-Topic: [Patch v4] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage. Thread-Index: AQHTFk9mu2WoGFopu0Oj52iwXAs4F6KHf0eA Date: Wed, 16 Aug 2017 21:27:17 +0000 Message-ID: References: <1502860836-14164-1-git-send-email-eric.dong@intel.com> In-Reply-To: <1502860836-14164-1-git-send-email-eric.dong@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Subject: Re: [Patch v4] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2017 21:24:53 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Eric, This looks good. The only minor comment is a code style issue for the parameter indent in the calls to AllocateCopyPool(). Should look like the following: SupportBitMask =3D AllocateCopyPool ( PcdGetSize (PcdCpuFeaturesSupport), PcdGetPtr (PcdCpuFeaturesSupport) ); With this change, Reviewed-by: Kinney, Michael D Mike > -----Original Message----- > From: Dong, Eric > Sent: Tuesday, August 15, 2017 10:21 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Shao, Ming > ; Kinney; Kinney, Michael D > > Subject: [Patch v4] UefiCpuPkg RegisterCpuFeaturesLib: Fix > buffer pointer error usage. >=20 > Current code allocate buffer for the pointer which later get > value > from PCD database. but current code error use "=3D" for this case. > Use AllocateCopyPool instead to fix it. >=20 > V2 enhanced to directly use AllocateCopyPool to get the PCD > value. > V3 enhanced to avoid using local temp variable. > V4 enhanced to keep the functions to get the pcd values. >=20 > Cc: Ruiyu Ni > Cc: Shao Ming > Cc: Kinney, Michael D > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 16 > ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > diff --git > a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > index 474aea3..b8f76f1 100644 > --- > a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > +++ > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > @@ -60,13 +60,13 @@ GetSupportPcds ( > VOID > ) > { > - UINTN BitMaskSize; > UINT8 *SupportBitMask; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSupport); > - SupportBitMask =3D AllocateZeroPool (BitMaskSize); > + SupportBitMask =3D AllocateCopyPool ( > + PcdGetSize (PcdCpuFeaturesSupport), > + PcdGetPtr (PcdCpuFeaturesSupport) > + ); > ASSERT (SupportBitMask !=3D NULL); > - SupportBitMask =3D (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport); >=20 > return SupportBitMask; > } > @@ -81,13 +81,13 @@ GetConfigurationPcds ( > VOID > ) > { > - UINTN BitMaskSize; > UINT8 *SupportBitMask; >=20 > - BitMaskSize =3D PcdGetSize (PcdCpuFeaturesUserConfiguration); > - SupportBitMask =3D AllocateZeroPool (BitMaskSize); > + SupportBitMask =3D AllocateCopyPool ( > + PcdGetSize (PcdCpuFeaturesUserConfiguration), > + PcdGetPtr (PcdCpuFeaturesUserConfiguration) > + ); > ASSERT (SupportBitMask !=3D NULL); > - SupportBitMask =3D (UINT8 *) PcdGetPtr > (PcdCpuFeaturesUserConfiguration); >=20 > return SupportBitMask; > } > -- > 2.7.0.windows.1