I wanted to add this code for pointer  validation across the driver. This would 
be even better than asserting non NULL.

During an object initialization:

#if DBG
Instance->signature = instance;
#endif

When an object if fetched from a hash table  of any other data structure:

ASSERT(instance->signature == instance);

I will add this to the pid hash primitives and we will add later for other 
objects like vPort.
Thanks,
Eitan

-----Original Message-----
From: Sorin Vinturis [mailto:[email protected]] 
Sent: Friday, October 24, 2014 2:15 AM
To: Eitan Eliahu; [email protected]
Subject: RE: [ovs-dev] [PATCH] datapath-windows:Remove user mode instance from 
pid hash on process termination

Hi Eitan,

Please see inline comment.

Acked-by: Sorin Vinturis <[email protected]>

Thanks,
Sorin

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Eitan Eliahu
Sent: Friday, October 24, 2014 6:17 AM
To: [email protected]
Subject: [ovs-dev] [PATCH] datapath-windows:Remove user mode instance from pid 
hash on process termination

The instance should be removed from pid-hash when vswitchd.exe terminates so 
the driver won't access it during packet miss (causing BSOD)

Signed-off-by: Eitan Eliahu <[email protected]>
---
 datapath-windows/ovsext/User.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c 
index db1b3de..f95f2ac 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -126,6 +126,11 @@ OvsCleanupPacketQueue(POVS_OPEN_INSTANCE instance)

[Sorin]
I would add an assert for the instance parameter at the beginning of 
OvsCleanupPacketQueue function, before accessing it.

    LIST_ENTRY tmp;
    PIRP irp = NULL;

+    ASSERT(instance);
    InitializeListHead(&tmp);
[Sorin]

     if (queue) {
         OvsFreeMemory(queue);
     }
+
+    OvsAcquireCtrlLock();
+    /* Remove the instance from pidHashArray */
+    OvsDelPidInstance(gOvsSwitchContext, instance->pid);
+    OvsReleaseCtrlLock();
 }
 
 NTSTATUS
@@ -146,12 +151,6 @@ OvsSubscribeDpIoctl(PVOID instanceP,
     if (instance->packetQueue && !join) {
         /* unsubscribe */
         OvsCleanupPacketQueue(instance);
-
-        OvsAcquireCtrlLock();
-        /* Remove the instance from pidHashArray */
-        OvsDelPidInstance(gOvsSwitchContext, pid);
-        OvsReleaseCtrlLock();
-
     } else if (instance->packetQueue == NULL && join) {
         queue = (POVS_USER_PACKET_QUEUE) OvsAllocateMemory(sizeof *queue);
         if (queue == NULL) {
--
1.9.4.msysgit.0

_______________________________________________
dev mailing list
[email protected]
https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0A&m=vHr7iiYxaJd4TpWFX0%2FwzCBREvvV7nL%2FnUhFfIJO604%3D%0A&s=35095ef15069086a3541d97de1408b7506a1ac7795b75daf4028566665001091
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to