Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[reactos.git] / ntoskrnl / mm / freelist.c
index ba66cd7..0ff5297 100644 (file)
@@ -167,6 +167,7 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
     PPHYSICAL_PAGE Pfn1;
     INT LookForZeroedPages;
     ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
+    DPRINT1("ARM3-DEBUG: Being called with %I64x %I64x %I64x %lx %d %d\n", LowAddress, HighAddress, SkipBytes, TotalBytes, CacheAttribute, MdlFlags);
 
     //
     // Convert the low address into a PFN
@@ -344,7 +345,7 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
         // If we didn' tfind any pages at all, fail
         //
         DPRINT1("NO MDL PAGES!\n");
-        ExFreePool(Mdl);
+        ExFreePoolWithTag(Mdl, TAG_MDL);
         return NULL;
     }
 
@@ -492,15 +493,15 @@ MmReferencePage(PFN_NUMBER Pfn)
 
    DPRINT("MmReferencePage(PysicalAddress %x)\n", Pfn << PAGE_SHIFT);
 
-   if (Pfn == 0 || Pfn > MmHighestPhysicalPage)
-   {
-      return;
-   }
+   ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
+   ASSERT(Pfn != 0);
+   ASSERT(Pfn <= MmHighestPhysicalPage);
 
    Page = MiGetPfnEntry(Pfn);
    ASSERT(Page);
    ASSERT_IS_ROS_PFN(Page);
 
+   ASSERT(Page->u3.e2.ReferenceCount != 0);
    Page->u3.e2.ReferenceCount++;
 }
 
@@ -543,6 +544,7 @@ MmDereferencePage(PFN_NUMBER Pfn)
    ASSERT(Page);
    ASSERT_IS_ROS_PFN(Page);
 
+   ASSERT(Page->u3.e2.ReferenceCount != 0);
    Page->u3.e2.ReferenceCount--;
    if (Page->u3.e2.ReferenceCount == 0)
    {
@@ -551,7 +553,7 @@ MmDereferencePage(PFN_NUMBER Pfn)
 
         /* It's not a ROS PFN anymore */
         Page->u4.AweAllocation = FALSE;
-        ExFreePool(MI_GET_ROS_DATA(Page));
+        ExFreePoolWithTag(MI_GET_ROS_DATA(Page), 'RsPf');
         Page->RosMmData = 0;
 
         /* Bring it back into the free list */