netdev_open() would previously increment a netdev's refcount without
holding a lock for it. This commit shifts the locking to protect it.

Found by inspection.

Signed-off-by: Joe Stringer <joestrin...@nicira.com>
---
 lib/netdev.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/netdev.c b/lib/netdev.c
index 6f997fd..e0b84bd 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -387,15 +387,15 @@ netdev_open(const char *name, const char *type, struct 
netdev **netdevp)
         error = 0;
     }
 
-    ovs_mutex_unlock(&netdev_mutex);
-    ovs_mutex_unlock(&netdev_class_mutex);
-
     if (!error) {
         netdev->ref_cnt++;
         *netdevp = netdev;
     } else {
         *netdevp = NULL;
     }
+    ovs_mutex_unlock(&netdev_mutex);
+    ovs_mutex_unlock(&netdev_class_mutex);
+
     return error;
 }
 
-- 
1.7.10.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to