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.

Driver modelKMDF

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:
  1. Prepare your code (use role type declarations).
  2. Run Static Driver Verifier.
  3. View and analyze the results.

For more information, see Using Static Driver Verifier to Find Defects in Drivers.

Applies to

WdfUsbTargetDeviceCreate
WdfUsbTargetDeviceCreateWithParameters

 

 

Send comments about this topic to Microsoft

Build date: 2/13/2014

Show:
© 2014 Microsoft. All rights reserved.