https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33949028fbceb25eedf9d…
commit 33949028fbceb25eedf9d71475ccfc4be063a6cd
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Mon Jun 7 10:40:20 2021 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Jun 19 12:17:18 2021 +0200
[NTOS:MM] Fix PFN lock usage
---
ntoskrnl/mm/balance.c | 6 ++++++
ntoskrnl/mm/freelist.c | 5 +----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c
index e6f1313b03f..f8fce014f56 100644
--- a/ntoskrnl/mm/balance.c
+++ b/ntoskrnl/mm/balance.c
@@ -77,6 +77,8 @@ NTSTATUS
NTAPI
MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
{
+ KIRQL OldIrql;
+
if (Page == 0)
{
DPRINT1("Tried to release page zero.\n");
@@ -85,8 +87,12 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
(void)InterlockedDecrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
+ OldIrql = MiAcquirePfnLock();
+
MmDereferencePage(Page);
+ MiReleasePfnLock(OldIrql);
+
return(STATUS_SUCCESS);
}
diff --git a/ntoskrnl/mm/freelist.c b/ntoskrnl/mm/freelist.c
index 69b8b6d1e96..fdd5d4b64da 100644
--- a/ntoskrnl/mm/freelist.c
+++ b/ntoskrnl/mm/freelist.c
@@ -566,10 +566,9 @@ NTAPI
MmDereferencePage(PFN_NUMBER Pfn)
{
PMMPFN Pfn1;
- KIRQL OldIrql;
DPRINT("MmDereferencePage(PhysicalAddress %x)\n", Pfn <<
PAGE_SHIFT);
- OldIrql = MiAcquirePfnLock();
+ MI_ASSERT_PFN_LOCK_HELD();
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
@@ -596,8 +595,6 @@ MmDereferencePage(PFN_NUMBER Pfn)
DPRINT("Legacy free: %lx\n", Pfn);
MiInsertPageInFreeList(Pfn);
}
-
- MiReleasePfnLock(OldIrql);
}
PFN_NUMBER