[NTOS]: Fix a bug in MmFindGapBottomUp which could make it return an address lower than what the caller said should be the lowest address.

svn path=/trunk/; revision=49439
This commit is contained in:
Sir Richard 2010-11-02 14:50:06 +00:00
parent 36429c0a64
commit c7b69d59e3

View file

@ -492,13 +492,16 @@ MmFindGapBottomUp(
break; break;
AlignedAddress = MM_ROUND_UP(PreviousNode->EndingAddress, Granularity); AlignedAddress = MM_ROUND_UP(PreviousNode->EndingAddress, Granularity);
if (Node->StartingAddress > AlignedAddress && if (AlignedAddress >= LowestAddress)
(ULONG_PTR)Node->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
{ {
DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress); if (Node->StartingAddress > AlignedAddress &&
return AlignedAddress; (ULONG_PTR)Node->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
{
DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
ASSERT(AlignedAddress >= LowestAddress);
return AlignedAddress;
}
} }
PreviousNode = Node; PreviousNode = Node;
} }
@ -508,6 +511,7 @@ MmFindGapBottomUp(
(ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length) (ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length)
{ {
DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress); DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
ASSERT(AlignedAddress >= LowestAddress);
return AlignedAddress; return AlignedAddress;
} }
@ -517,6 +521,7 @@ MmFindGapBottomUp(
(ULONG_PTR)FirstNode->StartingAddress - (ULONG_PTR)AlignedAddress >= Length) (ULONG_PTR)FirstNode->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
{ {
DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress); DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
ASSERT(AlignedAddress >= LowestAddress);
return AlignedAddress; return AlignedAddress;
} }