]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Pool.c
Check InternalAllocPoolByIndex status before refer buffer.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Pool.c
index 34dcc93f1ab4cedfe080308c719d3276782e9f41..761988e4162b840c9a0622a4df456bcf871f8508 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Memory pool management functions.\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -120,6 +120,7 @@ InternalAllocPoolByIndex (
 \r
   ASSERT (PoolIndex <= MAX_POOL_INDEX);\r
   Status = EFI_SUCCESS;\r
+  Hdr = NULL;\r
   if (PoolIndex == MAX_POOL_INDEX) {\r
     Status = SmmInternalAllocatePages (AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES (MAX_POOL_SIZE << 1), &Address);\r
     if (EFI_ERROR (Status)) {\r
@@ -228,7 +229,9 @@ SmmInternalAllocatePool (
   }\r
 \r
   Status = InternalAllocPoolByIndex (PoolIndex, &FreePoolHdr);\r
-  *Buffer = &FreePoolHdr->Header + 1;\r
+  if (!EFI_ERROR(Status)) {\r
+    *Buffer = &FreePoolHdr->Header + 1;\r
+  }\r
   return Status;\r
 }\r
 \r