Fix MmAllocatePageForMdl when it cannot allocate as much memory as
requested.
Modified: trunk/reactos/ntoskrnl/mm/mdl.c
_____
Modified: trunk/reactos/ntoskrnl/mm/mdl.c
--- trunk/reactos/ntoskrnl/mm/mdl.c 2005-01-14 14:11:13 UTC (rev
13041)
+++ trunk/reactos/ntoskrnl/mm/mdl.c 2005-01-14 14:47:03 UTC (rev
13042)
@@ -637,10 +637,9 @@
memory. When a driver wants to access physical memory described
by a
sub-MDL it must map the sub-MDL using
MmGetSystemAddressForMdlSafe.
- Konstantin Gusev
+ Konstantin Gusev
+ */
-*/
-
PMDL Mdl;
PPFN_TYPE Pages;
ULONG NumberOfPagesWanted, NumberOfPagesAllocated;
@@ -652,7 +651,11 @@
SkipBytes.QuadPart, Totalbytes);
/* SkipBytes must be a multiple of the page size */
- ASSERT((SkipBytes.QuadPart % PAGE_SIZE) == 0);
+ if ((SkipBytes.QuadPart % PAGE_SIZE) != 0)
+ {
+ DPRINT1("Warning: SkipBytes is not a multiple of PAGE_SIZE\n");
+ return NULL;
+ }
/* Allocate memory for the MDL */
Mdl = MmCreateMdl(NULL, 0, Totalbytes);
@@ -690,6 +693,11 @@
ExFreePool(Mdl);
Mdl = NULL;
}
+ else if (NumberOfPagesWanted > 0)
+ {
+ Mdl->ByteCount = (ULONG)(NumberOfPagesAllocated * PAGE_SIZE);
+ /* FIXME: I don't know if Mdl->Size should also be changed --
blight */
+ }
return Mdl;
}
Show replies by date