Do not take extra ActiveNBL when holding TransitionLock
The transition lock ensures that TunPause won't drop its last reference until the shared transition lock is dropped. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
34e61dc3b0
commit
ef12ddb2be
6
wintun.c
6
wintun.c
@ -670,8 +670,6 @@ TunSendNetBufferLists(
|
|||||||
{
|
{
|
||||||
TUN_CTX *Ctx = (TUN_CTX *)MiniportAdapterContext;
|
TUN_CTX *Ctx = (TUN_CTX *)MiniportAdapterContext;
|
||||||
|
|
||||||
InterlockedIncrement64(&Ctx->ActiveNBLCount);
|
|
||||||
|
|
||||||
KIRQL Irql = ExAcquireSpinLockShared(&Ctx->TransitionLock);
|
KIRQL Irql = ExAcquireSpinLockShared(&Ctx->TransitionLock);
|
||||||
LONG Flags = InterlockedGet(&Ctx->Flags);
|
LONG Flags = InterlockedGet(&Ctx->Flags);
|
||||||
NDIS_STATUS Status;
|
NDIS_STATUS Status;
|
||||||
@ -691,7 +689,6 @@ TunSendNetBufferLists(
|
|||||||
|
|
||||||
cleanup_ExReleaseSpinLockShared:
|
cleanup_ExReleaseSpinLockShared:
|
||||||
ExReleaseSpinLockShared(&Ctx->TransitionLock, Irql);
|
ExReleaseSpinLockShared(&Ctx->TransitionLock, Irql);
|
||||||
TunCompletePause(Ctx, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MINIPORT_CANCEL_SEND TunCancelSend;
|
static MINIPORT_CANCEL_SEND TunCancelSend;
|
||||||
@ -897,7 +894,7 @@ TunDispatchWrite(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
|
|||||||
goto cleanup_ExReleaseSpinLockShared;
|
goto cleanup_ExReleaseSpinLockShared;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterlockedAdd64(&Ctx->ActiveNBLCount, NblCount + 1);
|
InterlockedAdd64(&Ctx->ActiveNBLCount, NblCount);
|
||||||
*MdlRefcount = NblCount;
|
*MdlRefcount = NblCount;
|
||||||
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
|
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
|
||||||
{
|
{
|
||||||
@ -912,7 +909,6 @@ TunDispatchWrite(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExReleaseSpinLockShared(&Ctx->TransitionLock, Irql);
|
ExReleaseSpinLockShared(&Ctx->TransitionLock, Irql);
|
||||||
TunCompletePause(Ctx, TRUE);
|
|
||||||
TunCompleteRequest(Ctx, Irp, STATUS_SUCCESS, IO_NETWORK_INCREMENT);
|
TunCompleteRequest(Ctx, Irp, STATUS_SUCCESS, IO_NETWORK_INCREMENT);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user