InitFreeNull rule (kmdf)

The InitFreeNull rule specifies that DDIs receiving PWDFDEVICE_INIT as a parameter cannot be called by using a NULL pointer to a WDFDEVICE_INIT structure.

The framework-supplied methods initialize the WDFDEVICE_INIT structure. When the driver calls WdfDeviceCreate to create either a functional device object (FDO) or a physical device object (PDO), the WdfDeviceCreate method sets the first parameter to NULL if it succeeds.

If the driver encounters an error when it calls a device object initialization method or WdfDeviceCreate, the driver must call WdfDeviceInitFree. After a successful call to WdfDeviceInitFree, you should set the pointer to the WDFDEVICE_INIT structure to NULL (PWDFDEVICE_INIT=NULL).

Driver modelKMDF

How to test

At compile time

Run Static Driver Verifier and specify the InitFreeNull 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

WdfDeviceCreate
WdfDeviceInitAssignName
WdfDeviceInitAssignSDDLString
WdfDeviceInitAssignWdmIrpPreprocessCallback
WdfDeviceInitFree
WdfDeviceInitRegisterPnpStateChangeCallback
WdfDeviceInitRegisterPowerPolicyStateChangeCallback
WdfDeviceInitRegisterPowerStateChangeCallback
WdfPdoInitAddCompatibleID
WdfPdoInitAddDeviceText
WdfPdoInitAddHardwareID
WdfPdoInitAssignDeviceID
WdfPdoInitAssignInstanceID
WdfPdoInitAssignRawDevice

See also

InitFreeDeviceCallback
InitFreeDeviceCreate
InitFreeDeviceCreateType2
PdoInitFreeDeviceCreateType2
InitFreeDeviceCreateType4
PdoInitFreeDeviceCallback
PdoInitFreeDeviceCreate
PdoInitFreeDeviceCreateType4

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft