OldPages = NumberOfPages;\r
\r
AdjustMemoryF (&Start, &NumberOfPages);\r
- if (NumberOfPages == 0) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
//\r
// It's safe to unset Guard page inside memory lock because there should\r
// be no memory allocation occurred in updating memory page attribute at\r
// marking it usable (from non-present to present).\r
//\r
UnsetGuardForMemory (OldStart, OldPages);\r
+ if (NumberOfPages == 0) {\r
+ return EFI_SUCCESS;\r
+ }\r
} else {\r
AdjustMemoryA (&Start, &NumberOfPages);\r
}\r
NoPagesGuarded = NoPages;\r
\r
AdjustMemoryF (&Memory, &NoPages);\r
+ //\r
+ // It's safe to unset Guard page inside memory lock because there should\r
+ // be no memory allocation occurred in updating memory page attribute at\r
+ // this point. And unsetting Guard page before free will prevent Guard\r
+ // page just freed back to pool from being allocated right away before\r
+ // marking it usable (from non-present to present).\r
+ //\r
+ UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);\r
if (NoPages > 0) {\r
- //\r
- // It's safe to unset Guard page inside memory lock because there should\r
- // be no memory allocation occurred in updating memory page attribute at\r
- // this point. And unsetting Guard page before free will prevent Guard\r
- // page just freed back to pool from being allocated right away before\r
- // marking it usable (from non-present to present).\r
- //\r
- UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);\r
CoreFreePoolPagesI (PoolType, Memory, NoPages);\r
}\r
}\r