BSOD from USB WDF driver

So I have recently received a dump from the field on a production USB driver that I have released. It’s strikingly similar, in fact it’s exact, to what is referenced in the following closed thread:

https://www.osronline.com/ShowThread.cfm?link=189879

In the thread the solution was an errata to pass DTMs, however - there is no “errata” to a driver in the field. I’m curious as to whether this is something I’ll need to provide a workaround for, or if it is indeed a problem under WDF that cannot be worked around. It would seem that from the feedback in the closed thread that if it could have been addressed in the driver, then that would have been the best fix.

Any comments on this topic would be great.

The stack is for a verification that you’ve stopped a pipe (using WdfIoTargetStop)- for which a continuous reader was configured- before the device is removed.

You are expected to do this in the D0Exit event handler [this is the pattern used in sample code].

Do you do that?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@silabs.com
Sent: Tuesday, November 30, 2010 11:56 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] BSOD from USB WDF driver

So I have recently received a dump from the field on a production USB driver that I have released. It’s strikingly similar, in fact it’s exact, to what is referenced in the following closed thread:

https://www.osronline.com/ShowThread.cfm?link=189879

In the thread the solution was an errata to pass DTMs, however - there is no “errata” to a driver in the field. I’m curious as to whether this is something I’ll need to provide a workaround for, or if it is indeed a problem under WDF that cannot be worked around. It would seem that from the feedback in the closed thread that if it could have been addressed in the driver, then that would have been the best fix.

Any comments on this topic would be great.

Here’s a snippet of my EvtD0Exit function - I think I know the problem. I recently added some code to do some device specific cleanup and a few other things once it’s been surprised removed, I think I just mistakenly put the WdfIoTargetStop in the if {} but not the else {}. I’m pretty certain I just need to pull that out and call the WdfIoTargetStop before I decide my device specific functionality.

NTSTATUS
EvtDeviceD0Exit(
IN WDFDEVICE Device,
IN WDF_POWER_DEVICE_STATE TargetState
)
{
NTSTATUS status = STATUS_SUCCESS;
DEVICE_EXTENSION deviceExtension;

PAGED_CODE();

deviceExtension = GetDeviceExtension (Device);

if (!deviceExtension->DeviceHasBeenRemoved)
{
//
// Stop the continuous reader
//
WdfIoTargetStop(
WdfUsbTargetPipeGetIoTarget(deviceExtension->Usb.WdfBulkReadPipe),
WdfIoTargetCancelSentIo
);

// Do device specific stuff
//…
}
else
{
// Do device specific stuff
//…
}

return status;
}

It appears from initial testing by the customer that found this problem that this was indeed the case. Thanks for the help, Bob. I consider this resolved, here is the corrected EvtD0Exit function:

NTSTATUS
EvtDeviceD0Exit(
IN WDFDEVICE Device,
IN WDF_POWER_DEVICE_STATE TargetState
)
{
NTSTATUS status = STATUS_SUCCESS;
DEVICE_EXTENSION deviceExtension;

PAGED_CODE();

deviceExtension = GetDeviceExtension (Device);

//
// Stop the continuous reader
//
WdfIoTargetStop(
WdfUsbTargetPipeGetIoTarget(deviceExtension->Usb.WdfBulkReadPipe),
WdfIoTargetCancelSentIo
);

if (!deviceExtension->DeviceHasBeenRemoved)
{
// Do device specific stuff
//…
}
else
{
// Do device specific stuff
//…
}

return status;
}