[NTOS:MM] Check that we don't add rmap for NULL process
authorJérôme Gardou <jerome.gardou@reactos.org>
Tue, 29 Dec 2020 18:50:59 +0000 (19:50 +0100)
committerJérôme Gardou <jerome.gardou@reactos.org>
Wed, 3 Feb 2021 08:41:23 +0000 (09:41 +0100)
ntoskrnl/mm/rmap.c

index 80576f4..c000953 100644 (file)
@@ -410,17 +410,11 @@ MmInsertRmap(PFN_NUMBER Page, PEPROCESS Process,
 
     if (!RMAP_IS_SEGMENT(Address))
     {
-        if (Process == NULL)
+        ASSERT(Process != NULL);
+        PrevSize = InterlockedExchangeAddUL(&Process->Vm.WorkingSetSize, PAGE_SIZE);
+        if (PrevSize >= Process->Vm.PeakWorkingSetSize)
         {
-            Process = PsInitialSystemProcess;
-        }
-        if (Process)
-        {
-            PrevSize = InterlockedExchangeAddUL(&Process->Vm.WorkingSetSize, PAGE_SIZE);
-            if (PrevSize >= Process->Vm.PeakWorkingSetSize)
-            {
-                Process->Vm.PeakWorkingSetSize = PrevSize + PAGE_SIZE;
-            }
+            Process->Vm.PeakWorkingSetSize = PrevSize + PAGE_SIZE;
         }
     }
 }
@@ -455,14 +449,8 @@ MmDeleteRmap(PFN_NUMBER Page, PEPROCESS Process,
             ExFreeToNPagedLookasideList(&RmapLookasideList, current_entry);
             if (!RMAP_IS_SEGMENT(Address))
             {
-                if (Process == NULL)
-                {
-                    Process = PsInitialSystemProcess;
-                }
-                if (Process)
-                {
-                    (void)InterlockedExchangeAddUL(&Process->Vm.WorkingSetSize, -PAGE_SIZE);
-                }
+                ASSERT(Process != NULL);
+                (void)InterlockedExchangeAddUL(&Process->Vm.WorkingSetSize, -PAGE_SIZE);
             }
             return;
         }