summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorHeyi Guo <heyi.guo@linaro.org>2015-06-08 09:24:31 +0000
committerlgao4 <lgao4@Edk2>2015-06-08 09:24:31 +0000
commit1365bedd48916c4d88eee778b24a00da23e08ff0 (patch)
tree1cb5552d6373c8651ce7f319c8fd4cb826c830c5 /MdeModulePkg/Core
parent8262037ff851b4beaa011ca96012876bf7c40f94 (diff)
downloadedk2-platforms-1365bedd48916c4d88eee778b24a00da23e08ff0.tar.xz
MdeModulePkg: Fix bug of AllocatePages for large alignment
DescEnd will be clipped for alignment in CoreFindFreePagesI, and it may fall below DescStart, when alignment is more than 16KB (included) and both DescStart and original DescEnd fall into a single range of such alignment. This results in a huge size (Negative number in unsigned type) for this descriptor, fulfilling the allocation requirement but failing to run ConvertPages; at last it causes occasional failure of AllocatePages. A simple comparison is added to ensure we would never get a negative number. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo <heyi.guo@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17575 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Dxe/Mem/Page.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index a92c865e17..f2efaf1278 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -1051,6 +1051,11 @@ CoreFindFreePagesI (
DescEnd = ((DescEnd + 1) & (~(Alignment - 1))) - 1;
+ // Skip if DescEnd is less than DescStart after alignment clipping
+ if (DescEnd < DescStart) {
+ continue;
+ }
+
//
// Compute the number of bytes we can used from this
// descriptor, and see it's enough to satisfy the request