]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PiSmmCore: Update FreePages to handle zero address and pages
authorLiming Gao <liming.gao@intel.com>
Thu, 1 Dec 2016 06:47:55 +0000 (14:47 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 12 Dec 2016 02:52:31 +0000 (10:52 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=278

Zero memory address or zero number pages are invalid to SmmFreePages().

Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Core/PiSmmCore/Page.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.h

index 5f19d7e6c911343e3c0ed2fc3ddaf6d7d7d16888..1bc8fd82c86713b935420fbb5ef76e4def331354 100644 (file)
@@ -861,7 +861,7 @@ InternalMergeNodes (
   @param[in]  AddRegion              If this memory is new added region.\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range.\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned.\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r
@@ -875,7 +875,7 @@ SmmInternalFreePagesEx (
   LIST_ENTRY      *Node;\r
   FREE_PAGE_LIST  *Pages;\r
 \r
-  if ((Memory & EFI_PAGE_MASK) != 0) {\r
+  if (((Memory & EFI_PAGE_MASK) != 0) || (Memory == 0) || (NumberOfPages == 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -933,7 +933,7 @@ SmmInternalFreePagesEx (
   @param[in]  NumberOfPages          The number of pages to free.\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range.\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned.\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r
@@ -954,7 +954,7 @@ SmmInternalFreePages (
   @param  NumberOfPages          The number of pages to free.\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range.\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned.\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r
index 8df1e500f0229604253ea61ea1946b3788447387..d1e77913023cbff46b47d7e8945fb6d33090ffea 100644 (file)
@@ -312,7 +312,7 @@ SmmInternalAllocatePages (
   @param  NumberOfPages          The number of pages to free\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r
@@ -330,7 +330,7 @@ SmmFreePages (
   @param  NumberOfPages          The number of pages to free\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r