From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 6A68721DFC89E for ; Mon, 14 Aug 2017 22:57:07 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 14 Aug 2017 22:59:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,376,1498546800"; d="scan'208";a="137509018" Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.51]) by orsmga005.jf.intel.com with ESMTP; 14 Aug 2017 22:59:30 -0700 From: Eric Dong To: edk2-devel@lists.01.org Cc: Ruiyu Ni , Shao Ming Date: Tue, 15 Aug 2017 13:59:28 +0800 Message-Id: <1502776768-12720-1-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [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 05:57:07 -0000 Current code allocate buffer for the pointer which later get value from PCD database. but current code error use "=" for this case. Use AllocateCopyPool instead to fix it. V2 enhanced to directly use AllocateCopyPool to get the PCD value. Cc: Ruiyu Ni Cc: Shao Ming Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong --- UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 474aea3..b3b2d84 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -64,9 +64,8 @@ GetSupportPcds ( UINT8 *SupportBitMask; BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - SupportBitMask = AllocateZeroPool (BitMaskSize); + SupportBitMask = AllocateCopyPool (BitMaskSize, (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport)); ASSERT (SupportBitMask != NULL); - SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport); return SupportBitMask; } @@ -85,9 +84,8 @@ GetConfigurationPcds ( UINT8 *SupportBitMask; BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration); - SupportBitMask = AllocateZeroPool (BitMaskSize); + SupportBitMask = AllocateCopyPool (BitMaskSize, (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration)); ASSERT (SupportBitMask != NULL); - SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration); return SupportBitMask; } -- 2.7.0.windows.1