https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d52031a4f1381282891f9f...
commit d52031a4f1381282891f9f97b0c5812356aa83dc Author: Thamatip Chitpong thamatip.chitpong@reactos.org AuthorDate: Tue Nov 19 11:17:41 2024 +0700 Commit: GitHub noreply@github.com CommitDate: Tue Nov 19 11:17:41 2024 +0700
[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. --- ntoskrnl/mm/section.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index f935e6f30c1..50609bac71c 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -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)