[bus/pnp] Add new child PDO node removal logic
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Fri, 24 Dec 2010 01:53:59 +0000 (20:53 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Fri, 24 Dec 2010 03:46:48 +0000 (22:46 -0500)
To WvBusPnpRemoveDev_().  It will walk the new child PDO
node list and drop references for each PDO.

src/winvblock/bus/pnp.c

index e9f7aba..8275e20 100644 (file)
@@ -87,6 +87,7 @@ static NTSTATUS STDCALL WvBusPnpRemoveDev_(IN WV_SP_BUS_T bus, IN PIRP irp) {
     PDEVICE_OBJECT lower;
     WV_SP_DEV_T dev = &bus->Dev;
     WV_SP_DEV_T walker, next;
+    PLIST_ENTRY node_link;
 
     if (!(io_stack_loc->Control & SL_PENDING_RETURNED)) {
         /* Enqueue the IRP. */
@@ -118,6 +119,19 @@ static NTSTATUS STDCALL WvBusPnpRemoveDev_(IN WV_SP_BUS_T bus, IN PIRP irp) {
         WvDevFree(walker);
         walker = next;
       }
+    node_link = &bus->BusPrivate_.Nodes;
+    while ((node_link = node_link->Flink) != &bus->BusPrivate_.Nodes) {
+        WV_SP_BUS_NODE node = CONTAINING_RECORD(
+            node_link,
+            WV_S_BUS_NODE,
+            BusPrivate_.Link
+          );
+
+        DBG("Removing PDO from bus...\n");
+        RemoveEntryList(&node->BusPrivate_.Link);
+        ObDereferenceObject(node->BusPrivate_.Pdo);
+        bus->BusPrivate_.NodeCount--;
+      }
     /* Somewhat redundant, since the bus will be freed shortly. */
     bus->Children = 0;
     bus->first_child = NULL;