Hello alltogether,
I have two similar microcontrollers on one circuit board that are each
polled by its driver (using the same because controllers are technical
the same). I made following notice.
On reboot the attached computer the 2 devices are cleanly unloaded. No
errors.
On SURPRISE_REMOVE of both devices AND setting breakpoints into the
Dispatcher and follow up routines everything is fine. Same goes when
only one, regardless which device, is surprisingly disconnected.
If I disconnect both devices at the same or almost the same time (while
the "logout" of one device has not been completed) I get BSODs when
calling ExFreePool/IoFreeIrp for a polling Urb/Irp pair. I tried to
synchronize a OneDeviceRemovedEvent and keep the second pass waiting
until that event is signaled but it had no effect. (No multi-processor
machine)
I suggest because I signal the info in the deviceExtension belonging to
the "wrong" DeviceObject which is littered by ...
IoDetachDevice(deviceExtension->TopOfStackDeviceObject); // removes
lower phys.dev. object
IoDeleteDevice(DeviceObject); // removes this physical device
representation
If that is the case, is it possible to insert the information into
->TopOfStackDeviceObject->DeviceExtension and Detach the lower device
object in the 2nd pass of the device remove handler?