[ovs-dev] datapath-windows: Proper cleanup in case of driver init failure
diff mbox

Message ID 6FDA0CACF4BC624BBE12167875D71C9B9F0A10@CBSEX1.cloudbase.local
State Superseded
Headers show

Commit Message

Alin Serdean Sept. 1, 2015, 1:33 p.m. UTC
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>



-----Mesaj original-----
De la: dev [mailto:dev-bounces@openvswitch.org] În numele Sorin Vinturis
Trimis: Tuesday, September 1, 2015 3:16 PM
Către: dev@openvswitch.org
Subiect: [ovs-dev] [PATCH] datapath-windows: Proper cleanup in case of driver init failure

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>

---
 datapath-windows/ovsext/Driver.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

-- 
1.9.0.msysgit.0
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Patch
diff mbox

diff --git a/datapath-windows/ovsext/Driver.c b/datapath-windows/ovsext/Driver.c
index 13fcde2..853886e 100644
--- a/datapath-windows/ovsext/Driver.c
+++ b/datapath-windows/ovsext/Driver.c
@@ -139,18 +139,26 @@  DriverEntry(PDRIVER_OBJECT driverObject,
     driverObject->DriverUnload = OvsExtUnload;
 
     status = NdisFRegisterFilterDriver(driverObject,
-                                       (NDIS_HANDLE) gOvsExtDriverObject,
-                                       &driverChars, &gOvsExtDriverHandle);
+                                       (NDIS_HANDLE)gOvsExtDriverObject,
+                                       &driverChars,
+                                       &gOvsExtDriverHandle);
     if (status != NDIS_STATUS_SUCCESS) {
-        return status;
+        goto cleanup;
     }
 
-    /* Create the communication channel for usersapce. */
+    /* Create the communication channel for userspace. */
     status = OvsCreateDeviceObject(gOvsExtDriverHandle);
     if (status != NDIS_STATUS_SUCCESS) {
+        goto cleanup;
+    }
+
+cleanup:
+    if (status != NDIS_STATUS_SUCCESS){
         OvsCleanup();
-        NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
-        gOvsExtDriverHandle = NULL;
+        if (gOvsExtDriverHandle) {
+            NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
+            gOvsExtDriverHandle = NULL;
+        }
     }
 
     return status;