From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 9FD6221E14525 for ; Tue, 15 Aug 2017 08:25:50 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2017 08:28:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,378,1498546800"; d="scan'208";a="119204540" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga004.jf.intel.com with ESMTP; 15 Aug 2017 08:28:15 -0700 Received: from orsmsx163.amr.corp.intel.com (10.22.240.88) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 15 Aug 2017 08:28:15 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.211]) by ORSMSX163.amr.corp.intel.com ([169.254.9.158]) with mapi id 14.03.0319.002; Tue, 15 Aug 2017 08:28:15 -0700 From: "Kinney, Michael D" To: "Dong, Eric" , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "Ni, Ruiyu" , "Shao, Ming" Thread-Topic: [edk2] [Patch v2] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage. Thread-Index: AQHTFYuybLEAzXkjbUi2QNspe7t5MqKFiTrg Date: Tue, 15 Aug 2017 15:28:14 +0000 Message-ID: References: <1502776768-12720-1-git-send-email-eric.dong@intel.com> In-Reply-To: <1502776768-12720-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.139] MIME-Version: 1.0 Subject: Re: [Patch v2] 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: Tue, 15 Aug 2017 15:25:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Eric, You can eliminate the BitMaskSize local if you use the following: SupportBitMask =3D AllocateCopyPool ( PcdGetSize (PcdCpuFeaturesSupport), (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport) ); Mike > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On > Behalf Of Eric Dong > Sent: Monday, August 14, 2017 10:59 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Shao, Ming > > Subject: [edk2] [Patch v2] 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. >=20 > Cc: Ruiyu Ni > Cc: Shao Ming > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- >=20 > UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize. > c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) >=20 > diff --git > a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > index 474aea3..b3b2d84 100644 > --- > a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > +++ > b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ > e.c > @@ -64,9 +64,8 @@ GetSupportPcds ( > UINT8 *SupportBitMask; >=20 > BitMaskSize =3D PcdGetSize (PcdCpuFeaturesSupport); > - SupportBitMask =3D AllocateZeroPool (BitMaskSize); > + SupportBitMask =3D AllocateCopyPool (BitMaskSize, (UINT8 *) > PcdGetPtr (PcdCpuFeaturesSupport)); > ASSERT (SupportBitMask !=3D NULL); > - SupportBitMask =3D(UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport); >=20 > return SupportBitMask; > } > @@ -85,9 +84,8 @@ GetConfigurationPcds ( > UINT8 *SupportBitMask; >=20 > BitMaskSize =3D PcdGetSize (PcdCpuFeaturesUserConfiguration); > - SupportBitMask =3D AllocateZeroPool (BitMaskSize); > + SupportBitMask =3D AllocateCopyPool (BitMaskSize, (UINT8 *) > PcdGetPtr (PcdCpuFeaturesUserConfiguration)); > ASSERT (SupportBitMask !=3D NULL); > - SupportBitMask =3D (UINT8 *) PcdGetPtr > (PcdCpuFeaturesUserConfiguration); >=20 > return SupportBitMask; > } > -- > 2.7.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel