summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Switch.c
diff options
context:
space:
mode:
authorSorin Vinturis <svinturis@cloudbasesolutions.com>2014-10-27 19:26:49 +0000
committerBen Pfaff <blp@nicira.com>2014-10-28 08:01:22 -0700
commit3a6de110099860e0cc5f518b5f91a5db19fcc05d (patch)
tree15fd6e2ed58fb8db51f7218212bc2356ec957c3b /datapath-windows/ovsext/Switch.c
parent777d2bbd46f00594a88f546fe270232c8962d5e7 (diff)
downloadopenvswitch-3a6de110099860e0cc5f518b5f91a5db19fcc05d.tar.gz
datapath-windows: Fix BSOD caused by DV due to memory leaks.
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@cloudbasesolutions.com> Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com> Reported-at: https://github.com/openvswitch/ovs-issues/issues/50 Acked-by: Eitan Eliahu <eliahue@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/Switch.c')
-rw-r--r--datapath-windows/ovsext/Switch.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index f44550078..020300cb6 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -47,7 +47,7 @@ static NDIS_STATUS OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
POVS_SWITCH_CONTEXT *switchContextOut);
static NDIS_STATUS OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext);
static VOID OvsDeleteSwitch(POVS_SWITCH_CONTEXT switchContext);
-static VOID OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext);
+static VOID OvsUninitSwitchContext(POVS_SWITCH_CONTEXT switchContext);
static NDIS_STATUS OvsActivateSwitch(POVS_SWITCH_CONTEXT switchContext);
@@ -205,6 +205,7 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
status = OvsTunnelFilterInitialize(gOvsExtDriverObject);
if (status != NDIS_STATUS_SUCCESS) {
+ OvsUninitSwitchContext(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);
+ OvsUninitSwitchContext(switchContext);
+ OvsFreeMemory(switchContext);
+ }
OVS_LOG_TRACE("Exit: deleted switch %p dpNo: %d", switchContext, dpNo);
}
@@ -422,7 +427,7 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
}
static VOID
-OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext)
+OvsUninitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
{
OVS_LOG_TRACE("Enter: Delete switchContext:%p", switchContext);
@@ -430,11 +435,16 @@ OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext)
ASSERT(switchContext->numVports == 0);
NdisFreeRWLock(switchContext->dispatchLock);
+ switchContext->dispatchLock = NULL;
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);