[dummy] Try to delete a dummy device on IRP_MN_REMOVE_DEVICE
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Mon, 3 Jan 2011 12:56:15 +0000 (07:56 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Mon, 3 Jan 2011 12:57:29 +0000 (07:57 -0500)
This isn't exactly right, since WvlBusRemoveNode() will
actually schedule the node removal, but the PDO deletion
could happen first.  We need thread synchronization, here.

src/winvblock/dummy.c

index caa694a..fb17339 100644 (file)
@@ -49,6 +49,8 @@ static NTSTATUS STDCALL WvDummyPnp(
     IN PIRP irp,
     IN UCHAR code
   ) {
+    NTSTATUS status;
+
     switch (code) {
         case IRP_MN_QUERY_ID:
           /* The WV_S_DEV_T extension points to the dummy IDs. */
@@ -58,7 +60,12 @@ static NTSTATUS STDCALL WvDummyPnp(
           return WvlIrpComplete(irp, 0, STATUS_SUCCESS);
 
         case IRP_MN_REMOVE_DEVICE:
-          return WvlIrpComplete(irp, 0, WvlBusRemoveNode(&dev->BusNode));
+          WvlBusRemoveNode(&dev->BusNode);
+          IoDeleteDevice(dev->Self);
+          /* dev->ext is the PnP IDs' data. */
+          wv_free(dev->ext);
+          wv_free(dev);
+          return WvlIrpComplete(irp, 0, STATUS_SUCCESS);
 
         default:
           return WvlIrpComplete(irp, 0, STATUS_NOT_SUPPORTED);