WdfDeviceInitFree - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// wdfdevice.h

VOID WdfDeviceInitFree(
  [in] PWDFDEVICE_INIT DeviceInit
);

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-wdfdevice-wdfdeviceinitfree)

WdfDeviceInitFree function

Description

[Applies to KMDF only]

The WdfDeviceInitFree method deallocates a WDFDEVICE_INIT structure.

Parameters

DeviceInit [in]

A pointer to a WDFDEVICE_INIT structure.

Remarks

If your driver receives a WDFDEVICE_INIT structure from a call to WdfPdoInitAllocate or WdfControlDeviceInitAllocate, and if the driver subsequently encounters an error when it calls a device object initialization method or WdfDeviceCreate, the driver must call WdfDeviceInitFree.

Your driver must not call WdfDeviceInitFree after it calls WdfDeviceCreate successfully.

Your driver does not need to call WdfDeviceInitFree if it received the WDFDEVICE_INIT structure as input to its EvtDriverDeviceAdd callback function, because the framework deletes the structure after the callback function returns.

For more information about calling WdfDeviceCreate, see Creating a Framework Device Object.

Examples

The following code example calls WdfDeviceInitFree if a call to WdfPdoInitAssignRawDevice fails.

NTSTATUS  status;

status = WdfPdoInitAssignRawDevice(
                                   pDeviceInit,
                                   &GUID_DEVCLASS_KEYBOARD
                                   );
if (!NT_SUCCESS(status)) {
    WdfDeviceInitFree(pDeviceInit);
    pDeviceInit = NULL;
    return STATUS;
}

See also

WdfDeviceCreate