[NTOS:MM] MmPurgeSegment: Fix missing MmDereferenceSegment cleanup (#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.
This commit is contained in:
Thamatip Chitpong 2024-11-19 11:17:41 +07:00 committed by GitHub
parent 2e3a080e10
commit d52031a4f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4838,13 +4838,6 @@ 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)
{
@ -4852,6 +4845,13 @@ MmPurgeSegment(
return FALSE;
}
Segment = MiGrabDataSection(SectionObjectPointer);
if (!Segment)
{
/* Nothing to purge */
return TRUE;
}
MmLockSectionSegment(Segment);
if (!Length || !Offset)