UsbDeviceCreateTarget rule (kmdf)
The UsbDeviceCreateTarget rule specifies that multiple WDFUSBDEVICE objects are not created while WDFUSBDEVICE object(s) that are currently in the device context are leaked.
For example, the EvtDevicePrepareHardware event callback function can be called multiple times when the system is trying to manage resources and needs to allocate a different chunk of memory for the driver. In this situation, the EvtDeviceReleaseHardware event callback function is called to unmap memory resources after the framework has initially called EvtDevicePrepareHardware. The EvtDevicePrepareHardware is then called again to map resources so that the driver can access memory that is assigned to the device. This rule checks that the driver first verifies that the target WDFUSBDEVICE is NULL and does not simply create a new device and replace the previous handle.
How to test
|At compile time|
Run Static Driver Verifier and specify the UsbDeviceCreateTarget rule.Use the following steps to run an analysis of your code:
For more information, see Using Static Driver Verifier to Find Defects in Drivers.