Used MmFreeVirtualMemory in MmDeleteTeb because MmFreeMemoryAreaByPtr doesn't free the region list entries.
Modified: trunk/reactos/ntoskrnl/mm/process.c

Modified: trunk/reactos/ntoskrnl/mm/process.c
--- trunk/reactos/ntoskrnl/mm/process.c	2005-07-31 23:48:42 UTC (rev 16929)
+++ trunk/reactos/ntoskrnl/mm/process.c	2005-08-01 00:06:18 UTC (rev 16930)
@@ -104,49 +104,23 @@
 }
 
 VOID
-MiFreePebPage(PVOID Context,
-              MEMORY_AREA* MemoryArea,
-              PVOID Address,
-              PFN_TYPE Page,
-              SWAPENTRY SwapEntry,
-              BOOLEAN Dirty)
-{
-    PEPROCESS Process = (PEPROCESS)Context;
-
-    if (Page != 0)
-    {
-        SWAPENTRY SavedSwapEntry;
-        SavedSwapEntry = MmGetSavedSwapEntryPage(Page);
-        if (SavedSwapEntry != 0)
-        {
-            MmFreeSwapPage(SavedSwapEntry);
-            MmSetSavedSwapEntryPage(Page, 0);
-        }
-        MmDeleteRmap(Page, Process, Address);
-        MmReleasePageMemoryConsumer(MC_USER, Page);
-    }
-    else if (SwapEntry != 0)
-    {
-        MmFreeSwapPage(SwapEntry);
-    }
-}
-
-VOID
 STDCALL
 MmDeleteTeb(PEPROCESS Process,
             PTEB Teb)
 {
     PMADDRESS_SPACE ProcessAddressSpace = &Process->AddressSpace;
+    PMEMORY_AREA MemoryArea;
 
     /* Lock the Address Space */
     MmLockAddressSpace(ProcessAddressSpace);
+    
+    MemoryArea = MmLocateMemoryAreaByAddress(ProcessAddressSpace, (PVOID)Teb);
+    if (MemoryArea)
+    {
+       /* Delete the Teb */
+       MmFreeVirtualMemory(Process, MemoryArea);
+    }
 
-    /* Delete the Stack */
-    MmFreeMemoryAreaByPtr(ProcessAddressSpace,
-                          Teb,
-                          MiFreePebPage,
-                          Process);
-
     /* Unlock the Address Space */
     MmUnlockAddressSpace(ProcessAddressSpace);
 }