]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance the error handling for AllocatePool and AllocatePages function.
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 27 Apr 2012 02:48:46 +0000 (02:48 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 27 Apr 2012 02:48:46 +0000 (02:48 +0000)
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13225 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/Mem/Page.c
MdeModulePkg/Core/Dxe/Mem/Pool.c
MdePkg/Include/Uefi/UefiSpec.h

index 2a8161554a554176202533830b8e01fe089067f4..4ec895c0a228aa3d772708b999f90b00e5534336 100644 (file)
@@ -1247,7 +1247,7 @@ CoreGetMemoryMap (
   @param  Buffer                 The address to return a pointer to the allocated\r
                                  pool\r
 \r
-  @retval EFI_INVALID_PARAMETER  PoolType not valid\r
+  @retval EFI_INVALID_PARAMETER  PoolType not valid or Buffer is NULL\r
   @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.\r
   @retval EFI_SUCCESS            Pool successfully allocated.\r
 \r
index 04844e3305fa9a21bdcca4ebede0799beba15c9b..b4a62b9f0c4988462a24e03cc854ed1b780199b9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory page management functions.\r
 \r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1103,6 +1103,10 @@ CoreAllocatePages (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (Memory == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;\r
 \r
   if  (MemoryType == EfiACPIReclaimMemory   ||\r
index 2808905eabc594e0e7ed64943033f566ad4aa93e..a435b9760c0e3e9dd812c7b75498efa4af2ad130 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory pool management functions.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -167,7 +167,7 @@ LookupPoolHead (
   @param  Buffer                 The address to return a pointer to the allocated\r
                                  pool\r
 \r
-  @retval EFI_INVALID_PARAMETER  PoolType not valid\r
+  @retval EFI_INVALID_PARAMETER  PoolType not valid or Buffer is NULL. \r
   @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.\r
   @retval EFI_SUCCESS            Pool successfully allocated.\r
 \r
@@ -190,6 +190,10 @@ CoreAllocatePool (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   *Buffer = NULL;\r
 \r
   //\r
index 7dbac451b237cbec4efad00723e76687e671c4e5..fb462895ce56c293fcc5584cb8aaaebad19fdb5d 100644 (file)
@@ -5,7 +5,7 @@
   If a code construct is defined in the UEFI 2.3 specification it must be included\r
   by this include file.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -127,6 +127,7 @@ typedef struct {
   @retval EFI_INVALID_PARAMETER 1) Type is not AllocateAnyPages or\r
                                 AllocateMaxAddress or AllocateAddress.\r
                                 2) MemoryType is in the range\r
+                                3) Memory is NULL.\r
                                 EfiMaxMemoryType..0x7FFFFFFF.\r
   @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
   @retval EFI_NOT_FOUND         The requested pages could not be found.\r
@@ -205,7 +206,7 @@ EFI_STATUS
 \r
   @retval EFI_SUCCESS           The requested number of bytes was allocated.\r
   @retval EFI_OUT_OF_RESOURCES  The pool requested could not be allocated.\r
-  @retval EFI_INVALID_PARAMETER PoolType was invalid.\r
+  @retval EFI_INVALID_PARAMETER PoolType was invalid or Buffer is NULL.\r
 \r
 **/\r
 typedef\r