summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-03-10 14:34:42 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-03-10 14:34:42 +0000
commit6203199177e6968f69485ac7d9823f91e8b907e0 (patch)
tree3b8670b024a967ecb352095d9cc0fcbe4bd2b193
parentff565d71e126590b2f702b08ccc04ce3d0bddea9 (diff)
Fix a bug that Pages*EFI_PAGES_SIZE might be a negative number.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7854 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Core/Pei/Memory/MemoryServices.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
index d447d688d..3e424ad1a 100644
--- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -128,6 +128,7 @@ PeiAllocatePages (
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
+ UINTN RemainingPages;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
Hob.Raw = PrivateData->HobList.Raw;
@@ -159,11 +160,10 @@ PeiAllocatePages (
//
// Verify that there is sufficient memory to satisfy the allocation
//
- if (*(FreeMemoryTop) - ((Pages * EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) <
- *(FreeMemoryBottom)) {
- DEBUG ((EFI_D_ERROR, "AllocatePages failed: No 0x%x Pages is available.\n", Pages));
- DEBUG ((EFI_D_ERROR, "There is only left 0x%x pages memory resource to be allocated.\n", \
- EFI_SIZE_TO_PAGES ((UINTN) (*(FreeMemoryTop) - *(FreeMemoryBottom)))));
+ RemainingPages = EFI_SIZE_TO_PAGES ((UINTN) (*FreeMemoryTop - *FreeMemoryBottom));
+ if ((INTN) (RemainingPages - EFI_SIZE_TO_PAGES (sizeof (EFI_HOB_MEMORY_ALLOCATION))) < Pages) {
+ DEBUG ((EFI_D_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64) Pages));
+ DEBUG ((EFI_D_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64) RemainingPages));
return EFI_OUT_OF_RESOURCES;
} else {
//