[NTOS]: Don't keep the address space locked when failing in NtFreeVirtualMemory. Dang this testbot is good at catching those bugs.

svn path=/trunk/; revision=55985
This commit is contained in:
Sir Richard 2012-03-04 02:56:16 +00:00
parent 0e20c445f1
commit 4c07bf2fcd

View file

@ -1825,7 +1825,6 @@ MiDecommitPages(IN PVOID StartingAddress,
// //
if (PteCount) MiProcessValidPteList(ValidPteList, PteCount); if (PteCount) MiProcessValidPteList(ValidPteList, PteCount);
MiUnlockWorkingSet(CurrentThread, &Process->Vm); MiUnlockWorkingSet(CurrentThread, &Process->Vm);
if (CommitReduction) DPRINT1("DBG-REDUCE: %lx\n", CommitReduction);
return CommitReduction; return CommitReduction;
} }
@ -3870,7 +3869,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
// //
// Finally lock the working set and remove the VAD from the VAD tree // Finally lock the working set and remove the VAD from the VAD tree
// //
MiLockWorkingSet(CurrentThread, &Process->Vm); MiLockWorkingSet(CurrentThread, AddressSpace);
ASSERT(Process->VadRoot.NumberGenericTableElements >= 1); ASSERT(Process->VadRoot.NumberGenericTableElements >= 1);
MiRemoveNode((PMMADDRESS_NODE)Vad, &Process->VadRoot); MiRemoveNode((PMMADDRESS_NODE)Vad, &Process->VadRoot);
} }
@ -3900,7 +3899,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
// the code path above when the caller sets a zero region size // the code path above when the caller sets a zero region size
// and the whole VAD is destroyed // and the whole VAD is destroyed
// //
MiLockWorkingSet(CurrentThread, &Process->Vm); MiLockWorkingSet(CurrentThread, AddressSpace);
ASSERT(Process->VadRoot.NumberGenericTableElements >= 1); ASSERT(Process->VadRoot.NumberGenericTableElements >= 1);
MiRemoveNode((PMMADDRESS_NODE)Vad, &Process->VadRoot); MiRemoveNode((PMMADDRESS_NODE)Vad, &Process->VadRoot);
} }
@ -3972,7 +3971,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
// around with process pages. // around with process pages.
// //
MiDeleteVirtualAddresses(StartingAddress, EndingAddress, NULL); MiDeleteVirtualAddresses(StartingAddress, EndingAddress, NULL);
MiUnlockWorkingSet(CurrentThread, &Process->Vm); MiUnlockWorkingSet(CurrentThread, AddressSpace);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
FinalPath: FinalPath:
@ -4069,6 +4068,7 @@ FinalPath:
// return whatever failure code was sent. // return whatever failure code was sent.
// //
FailPath: FailPath:
MiUnlockWorkingSet(CurrentThread, AddressSpace);
if (Attached) KeUnstackDetachProcess(&ApcState); if (Attached) KeUnstackDetachProcess(&ApcState);
if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process);
return Status; return Status;