Skip to content

Commit

Permalink
[NTOS:MM] MmPurgeSegment: Fix missing MmDereferenceSegment cleanup (r…
Browse files Browse the repository at this point in the history
…eactos#7509)

MiGrabDataSection adds a refcount. There is a missing MmDereferenceSegment cleanup in case of range check error.
Fix that by moving MiGrabDataSection calling code to after range check.
  • Loading branch information
TAN-Gaming authored Nov 19, 2024
1 parent 2e3a080 commit d52031a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ntoskrnl/mm/section.c
Original file line number Diff line number Diff line change
Expand Up @@ -4838,20 +4838,20 @@ MmPurgeSegment(
LARGE_INTEGER PurgeStart, PurgeEnd;
PMM_SECTION_SEGMENT Segment;

Segment = MiGrabDataSection(SectionObjectPointer);
if (!Segment)
{
/* Nothing to purge */
return TRUE;
}

PurgeStart.QuadPart = Offset ? Offset->QuadPart : 0LL;
if (Length && Offset)
{
if (!NT_SUCCESS(RtlLongLongAdd(PurgeStart.QuadPart, Length, &PurgeEnd.QuadPart)))
return FALSE;
}

Segment = MiGrabDataSection(SectionObjectPointer);
if (!Segment)
{
/* Nothing to purge */
return TRUE;
}

MmLockSectionSegment(Segment);

if (!Length || !Offset)
Expand Down

0 comments on commit d52031a

Please sign in to comment.