diff --git a/drivers/usb/usbstor/fdo.c b/drivers/usb/usbstor/fdo.c index 08efa25ce5f..9b44e13dbe2 100644 --- a/drivers/usb/usbstor/fdo.c +++ b/drivers/usb/usbstor/fdo.c @@ -135,7 +135,7 @@ USBSTOR_FdoHandleRemoveDevice( Status = IoCallDriver(DeviceExtension->LowerDeviceObject, Irp); /* Detach from the device stack */ - /* IoDetachDevice(DeviceExtension->LowerDeviceObject); */ //This crashes for some reason during unload + IoDetachDevice(DeviceExtension->LowerDeviceObject); /* Delete the device object */ IoDeleteDevice(DeviceObject); diff --git a/ntoskrnl/io/iomgr/device.c b/ntoskrnl/io/iomgr/device.c index 97643b680f8..44a7a9b070b 100644 --- a/ntoskrnl/io/iomgr/device.c +++ b/ntoskrnl/io/iomgr/device.c @@ -420,10 +420,10 @@ IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject) /* * Check if we have an attached device and fail if we're attached - * and still have a reference count. + * or still have a reference count. */ AttachedDeviceObject = DeviceObject->AttachedDevice; - if ((AttachedDeviceObject) && (DeviceObject->ReferenceCount)) return; + if ((AttachedDeviceObject) || (DeviceObject->ReferenceCount)) return; /* Check if we have a Security Descriptor */ if (DeviceObject->SecurityDescriptor)