* [Patch v2] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage.
@ 2017-08-15 5:59 Eric Dong
2017-08-15 15:28 ` Kinney, Michael D
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dong @ 2017-08-15 5:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Ruiyu Ni, Shao Ming
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 <ruiyu.ni@intel.com>
Cc: Shao Ming <ming.shao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch v2] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage.
2017-08-15 5:59 [Patch v2] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage Eric Dong
@ 2017-08-15 15:28 ` Kinney, Michael D
0 siblings, 0 replies; 2+ messages in thread
From: Kinney, Michael D @ 2017-08-15 15:28 UTC (permalink / raw)
To: Dong, Eric, edk2-devel@lists.01.org, Kinney, Michael D
Cc: Ni, Ruiyu, Shao, Ming
Eric,
You can eliminate the BitMaskSize local if you use the following:
SupportBitMask = 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 <ruiyu.ni@intel.com>; Shao, Ming
> <ming.shao@intel.com>
> Subject: [edk2] [Patch v2] UefiCpuPkg RegisterCpuFeaturesLib:
> Fix buffer pointer error usage.
>
> 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 <ruiyu.ni@intel.com>
> Cc: Shao Ming <ming.shao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>
> UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.
> c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> 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;
>
> 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
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-15 15:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15 5:59 [Patch v2] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage Eric Dong
2017-08-15 15:28 ` 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