mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:35:43 +00:00
[NTOS:MM] Always release PFN lock in MmDereferenceSegmentWithLock
All callers release it after calling it. CORE-17698
This commit is contained in:
parent
ecf3416f49
commit
6150dc994a
1 changed files with 9 additions and 20 deletions
|
@ -991,27 +991,21 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
MmDereferenceSegmentWithLock(PMM_SECTION_SEGMENT Segment, KIRQL OldIrql)
|
MmDereferenceSegmentWithLock(PMM_SECTION_SEGMENT Segment, KIRQL OldIrql)
|
||||||
{
|
{
|
||||||
BOOLEAN HaveLock = FALSE;
|
|
||||||
|
|
||||||
/* Lock the PFN lock because we mess around with SectionObjectPointers */
|
/* Lock the PFN lock because we mess around with SectionObjectPointers */
|
||||||
if (OldIrql == MM_NOIRQL)
|
if (OldIrql == MM_NOIRQL)
|
||||||
{
|
{
|
||||||
HaveLock = TRUE;
|
|
||||||
OldIrql = MiAcquirePfnLock();
|
OldIrql = MiAcquirePfnLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InterlockedDecrement64(Segment->ReferenceCount) > 0)
|
if (InterlockedDecrement64(Segment->ReferenceCount) > 0)
|
||||||
{
|
{
|
||||||
/* Nothing to do yet */
|
/* Nothing to do yet */
|
||||||
if (HaveLock)
|
MiReleasePfnLock(OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Segment->Flags |= MM_SEGMENT_INDELETE;
|
*Segment->Flags |= MM_SEGMENT_INDELETE;
|
||||||
|
MiReleasePfnLock(OldIrql);
|
||||||
if (HaveLock)
|
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
|
|
||||||
/* Flush the segment */
|
/* Flush the segment */
|
||||||
if (*Segment->Flags & MM_DATAFILE_SEGMENT)
|
if (*Segment->Flags & MM_DATAFILE_SEGMENT)
|
||||||
|
@ -1019,13 +1013,11 @@ MmDereferenceSegmentWithLock(PMM_SECTION_SEGMENT Segment, KIRQL OldIrql)
|
||||||
/* Free the page table. This will flush any remaining dirty data */
|
/* Free the page table. This will flush any remaining dirty data */
|
||||||
MmFreePageTablesSectionSegment(Segment, FreeSegmentPage);
|
MmFreePageTablesSectionSegment(Segment, FreeSegmentPage);
|
||||||
|
|
||||||
if (HaveLock)
|
OldIrql = MiAcquirePfnLock();
|
||||||
OldIrql = MiAcquirePfnLock();
|
|
||||||
/* Delete the pointer on the file */
|
/* Delete the pointer on the file */
|
||||||
ASSERT(Segment->FileObject->SectionObjectPointer->DataSectionObject == Segment);
|
ASSERT(Segment->FileObject->SectionObjectPointer->DataSectionObject == Segment);
|
||||||
Segment->FileObject->SectionObjectPointer->DataSectionObject = NULL;
|
Segment->FileObject->SectionObjectPointer->DataSectionObject = NULL;
|
||||||
if (HaveLock)
|
MiReleasePfnLock(OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
ObDereferenceObject(Segment->FileObject);
|
ObDereferenceObject(Segment->FileObject);
|
||||||
|
|
||||||
ExFreePoolWithTag(Segment, TAG_MM_SECTION_SEGMENT);
|
ExFreePoolWithTag(Segment, TAG_MM_SECTION_SEGMENT);
|
||||||
|
@ -1038,13 +1030,11 @@ MmDereferenceSegmentWithLock(PMM_SECTION_SEGMENT Segment, KIRQL OldIrql)
|
||||||
ULONG NrSegments;
|
ULONG NrSegments;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
if (HaveLock)
|
OldIrql = MiAcquirePfnLock();
|
||||||
OldIrql = MiAcquirePfnLock();
|
|
||||||
/* Delete the pointer on the file */
|
/* Delete the pointer on the file */
|
||||||
ASSERT(ImageSectionObject->FileObject->SectionObjectPointer->ImageSectionObject == ImageSectionObject);
|
ASSERT(ImageSectionObject->FileObject->SectionObjectPointer->ImageSectionObject == ImageSectionObject);
|
||||||
ImageSectionObject->FileObject->SectionObjectPointer->ImageSectionObject = NULL;
|
ImageSectionObject->FileObject->SectionObjectPointer->ImageSectionObject = NULL;
|
||||||
if (HaveLock)
|
MiReleasePfnLock(OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
|
|
||||||
ObDereferenceObject(ImageSectionObject->FileObject);
|
ObDereferenceObject(ImageSectionObject->FileObject);
|
||||||
|
|
||||||
|
@ -2128,8 +2118,8 @@ MmpDeleteSection(PVOID ObjectBody)
|
||||||
|
|
||||||
/* We just dereference the first segment */
|
/* We just dereference the first segment */
|
||||||
ASSERT(ImageSectionObject->RefCount > 0);
|
ASSERT(ImageSectionObject->RefCount > 0);
|
||||||
|
/* MmDereferenceSegmentWithLock releases PFN lock */
|
||||||
MmDereferenceSegmentWithLock(ImageSectionObject->Segments, OldIrql);
|
MmDereferenceSegmentWithLock(ImageSectionObject->Segments, OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2145,8 +2135,8 @@ MmpDeleteSection(PVOID ObjectBody)
|
||||||
KIRQL OldIrql = MiAcquirePfnLock();
|
KIRQL OldIrql = MiAcquirePfnLock();
|
||||||
Segment->SectionCount--;
|
Segment->SectionCount--;
|
||||||
|
|
||||||
|
/* MmDereferenceSegmentWithLock releases PFN lock */
|
||||||
MmDereferenceSegmentWithLock(Segment, OldIrql);
|
MmDereferenceSegmentWithLock(Segment, OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4264,9 +4254,9 @@ MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
||||||
/*
|
/*
|
||||||
* Someone actually created a section while we were not looking.
|
* Someone actually created a section while we were not looking.
|
||||||
* Drop our ref and deny.
|
* Drop our ref and deny.
|
||||||
|
* MmDereferenceSegmentWithLock releases Pfn lock
|
||||||
*/
|
*/
|
||||||
MmDereferenceSegmentWithLock(&ImageSectionObject->Segments[0], OldIrql);
|
MmDereferenceSegmentWithLock(&ImageSectionObject->Segments[0], OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4276,7 +4266,6 @@ MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
||||||
|
|
||||||
/* Dereference the first segment, this will free everything & release the lock */
|
/* Dereference the first segment, this will free everything & release the lock */
|
||||||
MmDereferenceSegmentWithLock(&ImageSectionObject->Segments[0], OldIrql);
|
MmDereferenceSegmentWithLock(&ImageSectionObject->Segments[0], OldIrql);
|
||||||
MiReleasePfnLock(OldIrql);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case MmFlushForWrite:
|
case MmFlushForWrite:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue