diff options
author | Simon Rozman <simon@rozman.si> | 2019-06-08 06:40:32 +0200 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-06-08 08:14:07 +0200 |
commit | 5c2a9a991e2830467e2b34d0d54ac5d75dc391bb (patch) | |
tree | 65f7d014a041dcd316b89c09a8e4ca7172486012 | |
parent | Document toolchain requirement (diff) | |
download | wintun-5c2a9a991e2830467e2b34d0d54ac5d75dc391bb.tar.xz wintun-5c2a9a991e2830467e2b34d0d54ac5d75dc391bb.zip |
Refactor IRP_MJ_CLOSE TransitionLock unlocking
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | wintun.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -854,13 +854,13 @@ static NTSTATUS TunDispatch(DEVICE_OBJECT *DeviceObject, IRP *Irp) case IRP_MJ_CLOSE: irql = ExAcquireSpinLockExclusive(&ctx->TransitionLock); ASSERT(InterlockedGet64(&ctx->Device.RefCount) > 0); - if (InterlockedDecrement64(&ctx->Device.RefCount) <= 0) { - ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql); + BOOLEAN last_handle = InterlockedDecrement64(&ctx->Device.RefCount) <= 0; + ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql); + if (last_handle) { if (ctx->MiniportAdapterHandle) TunIndicateStatus(ctx->MiniportAdapterHandle, MediaConnectStateDisconnected); TunQueueClear(ctx, NDIS_STATUS_SEND_ABORTED); - } else - ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql); + } IoReleaseRemoveLock(&ctx->Device.RemoveLock, stack->FileObject); status = STATUS_SUCCESS; |