diff mbox

[ovs-dev,V2,1/3] datapath-windows: Avoid using uninitialized gOvsExtDriverHandle

Message ID 1460968439-11604-1-git-send-email-pboca@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Paul Boca April 18, 2016, 8:33 a.m. UTC
Ensure gOvsExtDriverHandle is not used if initialization fails
Added PAGED_CODE() where needed

Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
---
 datapath-windows/ovsext/Datapath.c | 4 +++-
 datapath-windows/ovsext/Driver.c   | 9 +++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

Comments

Ben Pfaff April 21, 2016, 6:30 p.m. UTC | #1
On Mon, Apr 18, 2016 at 08:33:56AM +0000, Paul Boca wrote:
> Ensure gOvsExtDriverHandle is not used if initialization fails
> Added PAGED_CODE() where needed
> 
> Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
> Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>

Applied, thanks!
diff mbox

Patch

diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c
index 0a25af0..06f99b3 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -616,6 +616,7 @@  OvsOpenCloseDevice(PDEVICE_OBJECT deviceObject,
     POVS_DEVICE_EXTENSION ovsExt =
         (POVS_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(deviceObject);
 
+    PAGED_CODE();
     ASSERT(deviceObject == gOvsDeviceObject);
     ASSERT(ovsExt != NULL);
 
@@ -648,7 +649,7 @@  NTSTATUS
 OvsCleanupDevice(PDEVICE_OBJECT deviceObject,
                  PIRP irp)
 {
-
+    PAGED_CODE();
     PIO_STACK_LOCATION irpSp;
     PFILE_OBJECT fileObject;
 
@@ -696,6 +697,7 @@  OvsDeviceControl(PDEVICE_OBJECT deviceObject,
     NETLINK_FAMILY *nlFamilyOps;
     OVS_USER_PARAMS_CONTEXT usrParamsCtx;
 
+    PAGED_CODE();
 #ifdef DBG
     POVS_DEVICE_EXTENSION ovsExt =
         (POVS_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(deviceObject);
diff --git a/datapath-windows/ovsext/Driver.c b/datapath-windows/ovsext/Driver.c
index 80979ea..50c9614 100644
--- a/datapath-windows/ovsext/Driver.c
+++ b/datapath-windows/ovsext/Driver.c
@@ -60,6 +60,8 @@  static const GUID ovsExtGuid = {
       {0x8b, 0x47, 0x57, 0x82, 0x97, 0xad, 0x76, 0x23}
 };
 
+DRIVER_INITIALIZE DriverEntry;
+
 /* Declarations of callback functions for the filter driver. */
 DRIVER_UNLOAD OvsExtUnload;
 FILTER_NET_PNP_EVENT OvsExtNetPnPEvent;
@@ -141,6 +143,7 @@  DriverEntry(PDRIVER_OBJECT driverObject,
 
     driverObject->DriverUnload = OvsExtUnload;
 
+    gOvsExtDriverHandle = NULL;
     status = NdisFRegisterFilterDriver(driverObject,
                                        (NDIS_HANDLE)gOvsExtDriverObject,
                                        &driverChars,
@@ -152,16 +155,14 @@  DriverEntry(PDRIVER_OBJECT driverObject,
     /* Create the communication channel for userspace. */
     status = OvsCreateDeviceObject(gOvsExtDriverHandle);
     if (status != NDIS_STATUS_SUCCESS) {
+        NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
+        gOvsExtDriverHandle = NULL;
         goto cleanup;
     }
 
 cleanup:
     if (status != NDIS_STATUS_SUCCESS){
         OvsCleanup();
-        if (gOvsExtDriverHandle) {
-            NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
-            gOvsExtDriverHandle = NULL;
-        }
     }
 
     return status;