https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d932bdb9505e270830e0eb177b523f39d32d1f10

commit d932bdb9505e270830e0eb177b523f39d32d1f10
Author:     Jérôme Gardou <jerome.gar...@reactos.org>
AuthorDate: Fri Jan 22 09:30:55 2021 +0100
Commit:     Jérôme Gardou <jerome.gar...@reactos.org>
CommitDate: Wed Feb 3 09:41:22 2021 +0100

    [NTOS:MM] Fix locking when paging out
---
 ntoskrnl/mm/rmap.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c
index d1cfb584dce..21b5b246457 100644
--- a/ntoskrnl/mm/rmap.c
+++ b/ntoskrnl/mm/rmap.c
@@ -70,7 +70,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
     if (entry == NULL)
     {
         MiReleasePfnLock(OldIrql);
-        return STATUS_UNSUCCESSFUL;
+        goto WriteSegment;
     }
 
     Process = entry->Process;
@@ -176,6 +176,12 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
                     MmSetDirtyPage(Process, Address);
 
                     MmUnlockAddressSpace(AddressSpace);
+                    if (Address < MmSystemRangeStart)
+                    {
+                        ExReleaseRundownProtection(&Process->RundownProtect);
+                        ObDereferenceObject(Process);
+                    }
+
                     return STATUS_UNSUCCESSFUL;
                 }
             }
@@ -199,6 +205,11 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
                     MmSetDirtyPage(Process, Address);
 
                     MmUnlockAddressSpace(AddressSpace);
+                    if (Address < MmSystemRangeStart)
+                    {
+                        ExReleaseRundownProtection(&Process->RundownProtect);
+                        ObDereferenceObject(Process);
+                    }
                     return STATUS_UNSUCCESSFUL;
                 }
             }
@@ -256,12 +267,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
         KeBugCheck(MEMORY_MANAGEMENT);
     }
 
-    if (Address < MmSystemRangeStart)
-    {
-        ExReleaseRundownProtection(&Process->RundownProtect);
-        ObDereferenceObject(Process);
-    }
-
+WriteSegment:
     /* Now write this page to file, if needed */
     Segment = MmGetSectionAssociation(Page, &SegmentOffset);
     if (Segment)

Reply via email to