public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch v4] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage.
@ 2017-08-16  5:20 Eric Dong
  2017-08-16 21:27 ` Kinney, Michael D
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dong @ 2017-08-16  5:20 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Shao Ming, Kinney, Michael D

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>
---
 .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c       | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index 474aea3..b8f76f1 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -60,13 +60,13 @@ GetSupportPcds (
   VOID
   )
 {
-  UINTN                  BitMaskSize;
   UINT8                  *SupportBitMask;
 
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-  SupportBitMask = AllocateZeroPool (BitMaskSize);
+  SupportBitMask = AllocateCopyPool (
+          PcdGetSize (PcdCpuFeaturesSupport), 
+          PcdGetPtr (PcdCpuFeaturesSupport)
+          );
   ASSERT (SupportBitMask != NULL);
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);
 
   return SupportBitMask;
 }
@@ -81,13 +81,13 @@ GetConfigurationPcds (
   VOID
   )
 {
-  UINTN                  BitMaskSize;
   UINT8                  *SupportBitMask;
 
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);
-  SupportBitMask = AllocateZeroPool (BitMaskSize);
+  SupportBitMask = AllocateCopyPool (
+          PcdGetSize (PcdCpuFeaturesUserConfiguration), 
+          PcdGetPtr (PcdCpuFeaturesUserConfiguration)
+          );
   ASSERT (SupportBitMask != NULL);
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration);
 
   return SupportBitMask;
 }
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-16 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-16  5:20 [Patch v4] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage Eric Dong
2017-08-16 21:27 ` Kinney, Michael D

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox