[NTOS:IO] Do not free the active VPB (#9343)

IopDereferenceVpbAndFree frees a zero-reference VPB only while it is still
installed in RealDevice->Vpb. This can leave the device with a dangling
VPB pointer while detached VPBs are retained.

Reverse the identity test so only a detached, nonpersistent VPB is released
after its reference count reaches zero.

Reference:
- https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_vpb
This commit is contained in:
Ahmed Arif
2026-07-27 15:48:33 +03:00
committed by GitHub
parent 6c515f5aa6
commit 28373a9f84
+1 -1
View File
@@ -192,7 +192,7 @@ IopDereferenceVpbAndFree(IN PVPB Vpb)
Vpb->ReferenceCount--;
/* Check if we're out of references */
if (!Vpb->ReferenceCount && Vpb->RealDevice->Vpb == Vpb &&
if (!Vpb->ReferenceCount && Vpb->RealDevice->Vpb != Vpb &&
!(Vpb->Flags & VPB_PERSISTENT))
{
/* Release VPB lock */