summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorZeng, Star <star.zeng@intel.com>2021-01-21 17:39:44 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-01-21 14:30:06 +0000
commit6c5801be6ef36e35f0b4ff906a4c99d68ca6f69a (patch)
treee5e5b6564b7fb1d92ac942c2f77d930214b16b81 /UefiCpuPkg
parent45962a05da1b61696004ca9acf3afb15d6adefbf (diff)
downloadedk2-6c5801be6ef36e35f0b4ff906a4c99d68ca6f69a.tar.gz
edk2-6c5801be6ef36e35f0b4ff906a4c99d68ca6f69a.tar.bz2
edk2-6c5801be6ef36e35f0b4ff906a4c99d68ca6f69a.zip
UefiCpuPkg RegisterCpuFeaturesLib: NumberOfCpus may be uninitialized
NumberOfCpus local variable in GetAcpiCpuData will be uninitialized when CpuS3DataDxe runs before DxeRegisterCpuFeaturesLib (linked by CpuFeaturesDxe) because there is no code to initialize it at (AcpiCpuData != NULL) execution path. The issue is exposed after cefad282fb31aff3e1a6dcbd368cbbffc3fce900 and 38ee7bafa72f58982f99ac6f61eef160f80bad69. There was negligence in that code review. One further topic may be "Could EDK2 CI be enhanced to catch this kind of uninitialized local variable case?". :) This patch fixes this regression issue. Cc: Eric Dong <eric.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Star Zeng <star.zeng@intel.com> Message-Id: <20210121093944.1621-1-star.zeng@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
index 7bb9240402..60daa5cc87 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
@@ -957,6 +957,7 @@ GetAcpiCpuData (
//
// Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs
//
+ NumberOfCpus = AcpiCpuData->NumberOfCpus;
TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);
RegisterTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));
ASSERT (RegisterTable != NULL);