]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage.
authorEric Dong <eric.dong@intel.com>
Wed, 16 Aug 2017 05:20:36 +0000 (13:20 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 17 Aug 2017 01:17:22 +0000 (09:17 +0800)
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.
V3 enhanced to avoid using local temp variable.
V4 enhanced to keep the functions to get the pcd values.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Shao Ming <ming.shao@intel.com>
Cc: Kinney Michael D <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Kinney Michael D <michael.d.kinney@intel.com>
UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c

index 474aea31e950e715c9cd00a7f5f5be57de0ab8bb..b8f76f1ce6fe46878b10d4f220b832fe82c02bce 100644 (file)
@@ -60,13 +60,13 @@ GetSupportPcds (
   VOID\r
   )\r
 {\r
-  UINTN                  BitMaskSize;\r
   UINT8                  *SupportBitMask;\r
 \r
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
-  SupportBitMask = AllocateZeroPool (BitMaskSize);\r
+  SupportBitMask = AllocateCopyPool (\r
+          PcdGetSize (PcdCpuFeaturesSupport), \r
+          PcdGetPtr (PcdCpuFeaturesSupport)\r
+          );\r
   ASSERT (SupportBitMask != NULL);\r
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);\r
 \r
   return SupportBitMask;\r
 }\r
@@ -81,13 +81,13 @@ GetConfigurationPcds (
   VOID\r
   )\r
 {\r
-  UINTN                  BitMaskSize;\r
   UINT8                  *SupportBitMask;\r
 \r
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);\r
-  SupportBitMask = AllocateZeroPool (BitMaskSize);\r
+  SupportBitMask = AllocateCopyPool (\r
+          PcdGetSize (PcdCpuFeaturesUserConfiguration), \r
+          PcdGetPtr (PcdCpuFeaturesUserConfiguration)\r
+          );\r
   ASSERT (SupportBitMask != NULL);\r
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration);\r
 \r
   return SupportBitMask;\r
 }\r