mirror of
https://github.com/reactos/reactos.git
synced 2026-05-30 23:33:24 +08:00
[NTOS:MM] Fix memory leak in MiMapViewOfDataSection
If inserting the allocated VAD fails, MiMapViewOfDataSection will make no attempt to free the allocated VAD. Nor will it call MiDereferenceControlArea(ControlArea); like other failure return paths. This commit fixes this behavior. Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
This commit is contained in:
committed by
George Bișoc
parent
032c50f87c
commit
4f8bbd141e
@@ -1494,6 +1494,11 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePoolWithTag(Vad, 'ldaV');
|
||||
MiDereferenceControlArea(ControlArea);
|
||||
|
||||
KeAcquireGuardedMutex(&MmSectionCommitMutex);
|
||||
Segment->NumberOfCommittedPages -= QuotaCharge;
|
||||
KeReleaseGuardedMutex(&MmSectionCommitMutex);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -1506,6 +1511,13 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
||||
AllocationType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePoolWithTag(Vad, 'ldaV');
|
||||
MiDereferenceControlArea(ControlArea);
|
||||
|
||||
KeAcquireGuardedMutex(&MmSectionCommitMutex);
|
||||
Segment->NumberOfCommittedPages -= QuotaCharge;
|
||||
KeReleaseGuardedMutex(&MmSectionCommitMutex);
|
||||
|
||||
PsReturnProcessNonPagedPoolQuota(PsGetCurrentProcess(), sizeof(MMVAD_LONG));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user