Author: janderwald
Date: Tue Oct 23 05:42:17 2012
New Revision: 57599
URL:
http://svn.reactos.org/svn/reactos?rev=57599&view=rev
Log:
[NTOSKRNL]
- Unregister dope (device object power extension) from volume list when device object is
deleted
- Core-6691 #resolve
Modified:
trunk/reactos/ntoskrnl/include/internal/po.h
trunk/reactos/ntoskrnl/io/iomgr/device.c
trunk/reactos/ntoskrnl/po/povolume.c
Modified: trunk/reactos/ntoskrnl/include/internal/po.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/po.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/po.h [iso-8859-1] Tue Oct 23 05:42:17 2012
@@ -285,6 +285,11 @@
IN PDEVICE_OBJECT DeviceObject
);
+VOID
+NTAPI
+PoRemoveVolumeDevice(
+ IN PDEVICE_OBJECT DeviceObject);
+
//
// Power State routines
//
Modified: trunk/reactos/ntoskrnl/io/iomgr/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/device.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] Tue Oct 23 05:42:17 2012
@@ -1035,6 +1035,9 @@
/* Set the pending delete flag */
IoGetDevObjExtension(DeviceObject)->ExtensionFlags |= DOE_DELETE_PENDING;
+ /* Unlink with the power manager */
+ if (DeviceObject->Vpb) PoRemoveVolumeDevice(DeviceObject);
+
/* Check if the device object can be unloaded */
if (!DeviceObject->ReferenceCount) IopUnloadDevice(DeviceObject);
}
Modified: trunk/reactos/ntoskrnl/po/povolume.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/povolume.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/po/povolume.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/po/povolume.c [iso-8859-1] Tue Oct 23 05:42:17 2012
@@ -97,7 +97,52 @@
KeReleaseGuardedMutex(&PopVolumeLock);
}
}
-
+
+VOID
+NTAPI
+PoRemoveVolumeDevice(IN PDEVICE_OBJECT DeviceObject)
+{
+ PDEVICE_OBJECT_POWER_EXTENSION Dope;
+ PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
+ KIRQL OldIrql;
+ PAGED_CODE();
+
+ /* If the device already has the dope, return it */
+ DeviceExtension = IoGetDevObjExtension(DeviceObject);
+ if (!DeviceExtension->Dope)
+ {
+ /* no dope */
+ return;
+ }
+
+ /* Make sure we can flush safely */
+ KeAcquireGuardedMutex(&PopVolumeLock);
+
+ /* Get dope from device */
+ Dope = (PDEVICE_OBJECT_POWER_EXTENSION)DeviceExtension->Dope;
+
+ if (Dope->Volume.Flink)
+ {
+ /* Remove from volume from list */
+ RemoveEntryList(&Dope->Volume);
+ }
+
+ /* Allow flushes to go through */
+ KeReleaseGuardedMutex(&PopVolumeLock);
+
+ /* Now remove dope from device object */
+ KeAcquireSpinLock(&PopDopeGlobalLock, &OldIrql);
+
+ /* remove from dev obj */
+ DeviceExtension->Dope = NULL;
+
+ /* Release lock */
+ KeReleaseSpinLock(&PopDopeGlobalLock, OldIrql);
+
+ /* Free dope */
+ ExFreePoolWithTag(Dope, 'Dope');
+}
+
VOID
NTAPI
PopFlushVolumeWorker(IN PVOID Context)