]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg RegisterCpuFeaturesLib: NumberOfCpus may be uninitialized
authorZeng, Star <star.zeng@intel.com>
Thu, 21 Jan 2021 09:39:44 +0000 (17:39 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 21 Jan 2021 14:30:06 +0000 (14:30 +0000)
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>
UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c

index 7bb92404027f08390cce30da30c3eacd5112de0d..60daa5cc87f0cfdb2d93f71b02c6ae114e028cd9 100644 (file)
@@ -957,6 +957,7 @@ GetAcpiCpuData (
     //\r
     // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
     //\r
+    NumberOfCpus = AcpiCpuData->NumberOfCpus;\r
     TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
     RegisterTable  = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));\r
     ASSERT (RegisterTable != NULL);\r