diff --git a/reactos/ntoskrnl/io/iomgr/volume.c b/reactos/ntoskrnl/io/iomgr/volume.c index 460302bc561..7fe6df8a168 100644 --- a/reactos/ntoskrnl/io/iomgr/volume.c +++ b/reactos/ntoskrnl/io/iomgr/volume.c @@ -363,16 +363,12 @@ IopShutdownBaseFileSystems(IN PLIST_ENTRY ListHead) DEVICE_OBJECT, Queue.ListEntry); + /* Get the attached device */ + DeviceObject = IoGetAttachedDevice(DeviceObject); + ObReferenceObject(DeviceObject); IopInterlockedIncrementUlong(LockQueueIoDatabaseLock, (PULONG)&DeviceObject->ReferenceCount); - /* Check if we're attached */ - if (DeviceObject->AttachedDevice) - { - /* Get the attached device */ - DeviceObject = IoGetAttachedDevice(DeviceObject); - } - /* Build the shutdown IRP and call the driver */ Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, DeviceObject,