]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that FreePool is too early in FirmwarePerformanceDxe.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 May 2013 05:45:35 +0000 (05:45 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 May 2013 05:45:35 +0000 (05:45 +0000)
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14388 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c

index 8996fe2b6ba6028522909d883c1d657bb9196d85..f834778acdcfebb4cdda480a18fa2be9aeb56175 100644 (file)
@@ -356,14 +356,15 @@ InstallFirmwarePerformanceDataTable (
   //\r
   // Collect boot records from SMM drivers.\r
   //\r
   //\r
   // Collect boot records from SMM drivers.\r
   //\r
-  SmmBootRecordCommBuffer = AllocateZeroPool (SMM_BOOT_RECORD_COMM_SIZE);\r
-  ASSERT (SmmBootRecordCommBuffer != NULL);\r
-  SmmCommData = NULL;\r
+  SmmBootRecordCommBuffer = NULL;\r
+  SmmCommData             = NULL;\r
   Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication);\r
   if (!EFI_ERROR (Status)) {\r
     //\r
     // Initialize communicate buffer \r
     //\r
   Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication);\r
   if (!EFI_ERROR (Status)) {\r
     //\r
     // Initialize communicate buffer \r
     //\r
+    SmmBootRecordCommBuffer = AllocateZeroPool (SMM_BOOT_RECORD_COMM_SIZE);\r
+    ASSERT (SmmBootRecordCommBuffer != NULL);\r
     SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER*)SmmBootRecordCommBuffer;\r
     SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)SmmCommBufferHeader->Data;\r
     ZeroMem((UINT8*)SmmCommData, sizeof(SMM_BOOT_RECORD_COMMUNICATE));\r
     SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER*)SmmBootRecordCommBuffer;\r
     SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)SmmCommBufferHeader->Data;\r
     ZeroMem((UINT8*)SmmCommData, sizeof(SMM_BOOT_RECORD_COMMUNICATE));\r
@@ -393,7 +394,6 @@ InstallFirmwarePerformanceDataTable (
       ASSERT_EFI_ERROR(SmmCommData->ReturnStatus);\r
     }\r
   }\r
       ASSERT_EFI_ERROR(SmmCommData->ReturnStatus);\r
     }\r
   }\r
-  FreePool (SmmBootRecordCommBuffer);\r
 \r
   //\r
   // Prepare memory for Boot Performance table.\r
 \r
   //\r
   // Prepare memory for Boot Performance table.\r
@@ -440,6 +440,9 @@ InstallFirmwarePerformanceDataTable (
     if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) {\r
       FreePool (SmmCommData->BootRecordData);\r
     }\r
     if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) {\r
       FreePool (SmmCommData->BootRecordData);\r
     }\r
+    if (SmmBootRecordCommBuffer != NULL) {\r
+      FreePool (SmmBootRecordCommBuffer);\r
+    }\r
     if (mAcpiS3PerformanceTable != NULL) {\r
       FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));\r
     }\r
     if (mAcpiS3PerformanceTable != NULL) {\r
       FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));\r
     }\r
@@ -470,6 +473,10 @@ InstallFirmwarePerformanceDataTable (
     mAcpiBootPerformanceTable->Header.Length = (UINT32) (mAcpiBootPerformanceTable->Header.Length + SmmCommData->BootRecordSize);\r
     BootPerformanceData = BootPerformanceData + SmmCommData->BootRecordSize;\r
   }\r
     mAcpiBootPerformanceTable->Header.Length = (UINT32) (mAcpiBootPerformanceTable->Header.Length + SmmCommData->BootRecordSize);\r
     BootPerformanceData = BootPerformanceData + SmmCommData->BootRecordSize;\r
   }\r
+  if (SmmBootRecordCommBuffer != NULL) {\r
+    FreePool (SmmBootRecordCommBuffer);\r
+  }\r
+\r
   //\r
   // Save Boot Performance Table address to Variable for use in S4 resume.\r
   //\r
   //\r
   // Save Boot Performance Table address to Variable for use in S4 resume.\r
   //\r