[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 1/4] Apply PnP fixes analogous to those recently made in XENBUS



Code inspection in XENBUS highlighted some issues with the PnP code. The
same issues need to be fixed in XENVIF.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/fdo.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/xenvif/fdo.c b/src/xenvif/fdo.c
index 65d1b55..91d66dc 100644
--- a/src/xenvif/fdo.c
+++ b/src/xenvif/fdo.c
@@ -745,29 +745,30 @@ __FdoEnumerate(
     while (ListEntry != &Fdo->Dx->ListEntry) {
         PLIST_ENTRY     Next = ListEntry->Flink;
         PXENVIF_DX      Dx = CONTAINING_RECORD(ListEntry, XENVIF_DX, 
ListEntry);
-        PCHAR           Name = Dx->Name;
         PXENVIF_PDO     Pdo = Dx->Pdo;
-        BOOLEAN         Missing;
 
-        Name = PdoGetName(Pdo);
-        Missing = TRUE;
+        if (!PdoIsMissing(Pdo) && PdoGetDevicePnpState(Pdo) != Deleted) {
+            PCHAR           Name;
+            BOOLEAN         Missing;
 
-        // If the PDO already exists ans its name is in the class list then
-        // we don't want to remove it.
-        for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
-            PANSI_STRING Device = &Devices[Index];
+            Name = PdoGetName(Pdo);
+            Missing = TRUE;
 
-            if (Device->Length == 0)
-                continue;
+            // If the PDO already exists and its name is in the device list
+            // then we don't want to remove it.
+            for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
+                PANSI_STRING Device = &Devices[Index];
 
-            if (strcmp(Name, Device->Buffer) == 0) {
-                Missing = FALSE;
-                Device->Length = 0;  // avoid duplication
-                break;
+                if (Device->Length == 0)
+                    continue;
+
+                if (strcmp(Name, Device->Buffer) == 0) {
+                    Missing = FALSE;
+                    Device->Length = 0;  // avoid duplication
+                    break;
+                }
             }
-        }
 
-        if (!PdoIsMissing(Pdo) && PdoGetDevicePnpState(Pdo) != Deleted) {
             if (PdoIsEjectRequested(Pdo)) {
                 IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
             } else if (Missing) {
@@ -789,7 +790,7 @@ __FdoEnumerate(
         ListEntry = Next;
     }
 
-    // Walk the class list and create PDOs for any new classes
+    // Walk the class list and create PDOs for any new device
     for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
         PANSI_STRING Device = &Devices[Index];
 
@@ -1678,17 +1679,19 @@ FdoQueryDeviceRelations(
 
     __FdoAcquireMutex(Fdo);
 
-    for (ListEntry = Fdo->Dx->ListEntry.Flink;
-         ListEntry != &Fdo->Dx->ListEntry;
-         ListEntry = ListEntry->Flink) {
+    ListEntry = Fdo->Dx->ListEntry.Flink;
+    while (ListEntry != &Fdo->Dx->ListEntry) {
         PXENVIF_DX  Dx = CONTAINING_RECORD(ListEntry, XENVIF_DX, ListEntry);
         PXENVIF_PDO Pdo = Dx->Pdo;
+        PLIST_ENTRY Next = ListEntry->Flink;
 
         ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
 
         if (PdoGetDevicePnpState(Pdo) == Deleted &&
             PdoIsMissing(Pdo))
             PdoDestroy(Pdo);
+
+        ListEntry = Next;
     }
 
     __FdoReleaseMutex(Fdo);
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.