datapath-windows: Avoid BSOD when switch context is NULL
authorSorin Vinturis <svinturis@cloudbasesolutions.com>
Wed, 19 Nov 2014 07:16:32 +0000 (07:16 +0000)
committerGurucharan Shetty <gshetty@nicira.com>
Thu, 20 Nov 2014 15:18:23 +0000 (07:18 -0800)
I came around a BSOD that happened when trying to access pidHashLock
from the gOvsSwitchContext, which was NULL. The stop happened in
OvsAcquirePidHashLock function.

To reproduce this BSOD, make sure the extension is enabled and running,
disable it and, after that, execute 'ovs-dpctl.exe show'. The BSOD is
triggered afterwards.

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/53
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows/ovsext/Tunnel.c
datapath-windows/ovsext/User.c

index b55a223..fed58f1 100644 (file)
@@ -224,9 +224,10 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
     OvsCompletionList completionList;
     KIRQL irql;
     ULONG SendFlags = NDIS_SEND_FLAGS_SWITCH_DESTINATION_GROUP;
-    OVS_DATAPATH *datapath = &gOvsSwitchContext->datapath;
+    OVS_DATAPATH *datapath = NULL;
 
     ASSERT(gOvsSwitchContext);
+    datapath = &gOvsSwitchContext->datapath;
 
     /* Fill the tunnel key */
     status = OvsSlowPathDecapVxlan(pNbl, &tunnelKey);
index 96adb5c..8473f98 100644 (file)
@@ -141,10 +141,15 @@ OvsCleanupPacketQueue(POVS_OPEN_INSTANCE instance)
         OvsFreeMemory(queue);
     }
 
-    /* Remove the instance from pidHashArray */
-    OvsAcquirePidHashLock();
-    OvsDelPidInstance(gOvsSwitchContext, instance->pid);
-    OvsReleasePidHashLock();
+    /* Verify if gOvsSwitchContext exists. */
+    OvsAcquireCtrlLock();
+    if (gOvsSwitchContext) {
+        /* Remove the instance from pidHashArray */
+        OvsAcquirePidHashLock();
+        OvsDelPidInstance(gOvsSwitchContext, instance->pid);
+        OvsReleasePidHashLock();
+    }
+    OvsReleaseCtrlLock();
 }
 
 NTSTATUS