Skip to content

Commit

Permalink
datapath-windows: Avoid using uninitialized gOvsExtDriverHandle
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
Paul Boca authored and blp committed Apr 21, 2016
1 parent 110f7c7 commit 12f1ba4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion datapath-windows/ovsext/Datapath.c
Expand Up @@ -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);

Expand Down Expand Up @@ -648,7 +649,7 @@ NTSTATUS
OvsCleanupDevice(PDEVICE_OBJECT deviceObject,
PIRP irp)
{

PAGED_CODE();
PIO_STACK_LOCATION irpSp;
PFILE_OBJECT fileObject;

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions datapath-windows/ovsext/Driver.c
Expand Up @@ -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;
Expand Down Expand Up @@ -141,6 +143,7 @@ DriverEntry(PDRIVER_OBJECT driverObject,

driverObject->DriverUnload = OvsExtUnload;

gOvsExtDriverHandle = NULL;
status = NdisFRegisterFilterDriver(driverObject,
(NDIS_HANDLE)gOvsExtDriverObject,
&driverChars,
Expand All @@ -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;
Expand Down

0 comments on commit 12f1ba4

Please sign in to comment.