WdfDeviceInitFree

MSDN says that after a successful call to WdfDeviceCreate the framework will free up the WDFDEVICE_INIT struct and we should not do so ourselves. Does this mean that if a subsequent call fails, like the WdfControlDeviceInitSetShutdownNotification or WdfDeviceCreateSymbolicLink fails, we still dont need to free it up?

If WdfControlDeviceInitSetShutdownNotification fails you haven’t yet called WdfDeviceCreate so you need to free the init explicitly. WdfDeviceCreateSymbolicLink can only be called after create succeeded so you don’t need to free the init upon subsequent failures… You are conflating the failure of other APIs with a very simple concept. Simply if device create succeeds, it frees the init for you.

@Doron_Holan said:
You are conflating the failure of other APIs with a very simple concept. Simply if device create succeeds, it frees the init for you.

You are right, I was over thinking it, thanks for the confirmation though.

I was freeing it all the time, but it seems to only crash on WinBlue, probably the other OS builds handle the nullptr properly and ignore the WdfDeviceInitFree call.