Issues detaching device

Hi, im attaching a device in IoRegisterPlugPlayNotification (only once, this is checked with a global)
just for testing I tried to expose an IOCTL to deregister the notification (calling IoUnregisterPlugPlayNotification) , and then call IoDetachDevice and IoDeleteDevice

I have a pass through dispatch routines that simply call the lower device from the device extension pointer, and before detaching i wait on a rundown ref to be released (one which I acquire in the start of the pass through filter and release at the end of it)

when I issue the ioctl , I get a page fault bsod from the pass through dispatch routine, is there anything wrong in the sequece of operations I perform to deregister and detach my device here?