Wait-wake IRP completion and IoCancelIrp race

Doron,

Thank you for your answer.
Does your explanation applies to the power IRPs as well?

I am using the PoRequestPowerIrp to request the IRP. The MSDN states:
“The PowerCompletion routine performs any additional tasks the sender of the IRP requires after all other drivers have completed the IRP. It need not free the IRP; the power manager does that.”

Since the FUNCTION driver is not freeing the IRP directly I am not able to control when IoFreeIrp should be called.

Is there a way to control power manager on when should it free the IRP?

Best regards,
Marek Dabek