Hi Shenglei,

Please send a second patch series with the copyrights updated.

Thanks,
Nate

-----Original Message-----
From: Zhang, Shenglei 
Sent: Monday, September 2, 2019 5:30 AM
To: [email protected]
Cc: Kubacki, Michael A <[email protected]>; Chiu, Chasel 
<[email protected]>; Desimone, Nathaniel L 
<[email protected]>; Gao, Liming <[email protected]>
Subject: [PATCH 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used

MadtStructs, NewMadtTable and MaxMadtStructCount are not initialized before 
used or at the proper place. So assign values to them at the beginning and 
change the logic when freeing MadtStructs and NewMadtTable.

Cc: Michael Kubacki <[email protected]>
Cc: Chasel Chiu <[email protected]>
Cc: Nate DeSimone <[email protected]>
Cc: Liming Gao <[email protected]>
Signed-off-by: Shenglei Zhang <[email protected]>
---
 .../Acpi/AcpiTables/AcpiPlatform.c            | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c 
b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 5eb72792..85d1bd9a 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -867,13 +867,15 @@ InstallMadtFromScratch (
   UINT32                                              PcIoApicMask;
   UINTN                                               PcIoApicIndex;
 
+  MadtStructs = NULL;
+  NewMadtTable = NULL;
+  MaxMadtStructCount = 0;
+
   DetectApicIdMap();
 
   // Call for Local APIC ID Reorder
   SortCpuLocalApicInTable ();
 
-  NewMadtTable = NULL;
-
   MaxMadtStructCount = (UINT32) (
     MAX_CPU_NUM +    // processor local APIC structures
     MAX_CPU_NUM +    // processor local x2APIC structures
@@ -1115,14 +1117,15 @@ Done:
   //
   // Free memory
   //
-  for (MadtStructsIndex = 0; MadtStructsIndex < MaxMadtStructCount; 
MadtStructsIndex++) {
-    if (MadtStructs[MadtStructsIndex] != NULL) {
-      FreePool (MadtStructs[MadtStructsIndex]);
+  if (MadtStructs != NULL){
+    for (MadtStructsIndex = 0; MadtStructsIndex < MaxMadtStructCount; 
MadtStructsIndex++) {
+      if (MadtStructs[MadtStructsIndex] != NULL) {
+        FreePool (MadtStructs[MadtStructsIndex]);
+      }
     }
+    FreePool (MadtStructs);
   }
-
-  FreePool (MadtStructs);
-
+
   if (NewMadtTable != NULL) {
     FreePool (NewMadtTable);
   }
--
2.18.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#47087): https://edk2.groups.io/g/devel/message/47087
Mute This Topic: https://groups.io/mt/33110578/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to