[ovs-dev] [PATCH] datapath-windows: BSOD cause by DV due to memory leaks

Sorin Vinturis svinturis at cloudbasesolutions.com
Mon Oct 27 11:26:32 UTC 2014


If the OVS extension is enabled, Driver Verifier will issue a BSOD
due to memory leaks. This issue reproduces each time and the problem
is in the filter attach routine when the switch context is initialized.

Signed-off-by: Sorin Vinturis <svinturis at cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis at cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/50
---
 datapath-windows/ovsext/Switch.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index f445500..f8e72ac 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -205,6 +205,7 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
 
     status = OvsTunnelFilterInitialize(gOvsExtDriverObject);
     if (status != NDIS_STATUS_SUCCESS) {
+        OvsCleanupSwitchContext(switchContext);
         OvsFreeMemory(switchContext);
         goto create_switch_done;
     }
@@ -254,14 +255,18 @@ OvsExtDetach(NDIS_HANDLE filterModuleContext)
 VOID
 OvsDeleteSwitch(POVS_SWITCH_CONTEXT switchContext)
 {
-    UINT32 dpNo = switchContext->dpNo;
+    UINT32 dpNo = (UINT32) -1;
 
     OVS_LOG_TRACE("Enter: switchContext:%p", switchContext);
 
-    OvsTunnelFilterUninitialize(gOvsExtDriverObject);
-    OvsClearAllSwitchVports(switchContext);
-    OvsCleanupSwitchContext(switchContext);
-    OvsFreeMemory(switchContext);
+    if (switchContext)
+    {
+        dpNo = switchContext->dpNo;
+        OvsTunnelFilterUninitialize(gOvsExtDriverObject);
+        OvsClearAllSwitchVports(switchContext);
+        OvsCleanupSwitchContext(switchContext);
+        OvsFreeMemory(switchContext);
+    }
     OVS_LOG_TRACE("Exit: deleted switch %p  dpNo: %d", switchContext, dpNo);
 }
 
@@ -432,9 +437,13 @@ OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext)
     NdisFreeRWLock(switchContext->dispatchLock);
     NdisFreeSpinLock(&(switchContext->pidHashLock));
     OvsFreeMemory(switchContext->ovsPortNameHashArray);
+    switchContext->ovsPortNameHashArray = NULL;
     OvsFreeMemory(switchContext->portIdHashArray);
+    switchContext->portIdHashArray = NULL;
     OvsFreeMemory(switchContext->portNoHashArray);
+    switchContext->portNoHashArray = NULL;
     OvsFreeMemory(switchContext->pidHashArray);
+    switchContext->pidHashArray = NULL;
     OvsDeleteFlowTable(&switchContext->datapath);
     OvsCleanupBufferPool(switchContext);
     OVS_LOG_TRACE("Exit: Delete switchContext: %p", switchContext);
-- 
1.9.0.msysgit.0



More information about the dev mailing list