[NTOSKRNL]

- Fix the unload path
- This does expose some bugs: 2 cont-able assertions in ARM3 after unplugging a USB storage device (during usbstor unload), HID unload doesn't seem to work correctly (somebody still has references to the devices), other issues may pop up too

svn path=/trunk/; revision=56069
This commit is contained in:
Cameron Gutman 2012-03-06 22:50:13 +00:00
parent ca8ba290ce
commit 092d67d890

View file

@ -377,8 +377,6 @@ IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
/* Check if deletion is pending */
if (ThisExtension->ExtensionFlags & DOE_DELETE_PENDING)
{
if (!(ThisExtension->ExtensionFlags & DOE_UNLOAD_PENDING)) return;
if (DeviceObject->AttachedDevice)
{
DPRINT("Device object is in the middle of a device stack\n");
@ -415,7 +413,7 @@ IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
*/
if (DeviceObject->ReferenceCount)
{
DPRINT("Device object still has %d references\n", DeviceObject->ReferenceCount);
DPRINT("Device object still has %d references\n", DeviceObject->ReferenceCount);
return;
}
@ -435,6 +433,17 @@ IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
DeviceObject = DeviceObject->NextDevice;
}
/* Loop all the device objects */
DeviceObject = DriverObject->DeviceObject;
while (DeviceObject)
{
/* Set the unload pending flag */
IoGetDevObjExtension(DeviceObject)->ExtensionFlags |= DOE_UNLOAD_PENDING;
/* Go to the next device */
DeviceObject = DeviceObject->NextDevice;
}
DPRINT1("Unloading driver '%wZ' (automatic)\n", &DriverObject->DriverName);
/* Set the unload invoked flag */