summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Stringer <joestringer@nicira.com>2014-05-02 11:55:05 +1200
committerJoe Stringer <joestringer@nicira.com>2014-05-05 12:21:13 +1200
commit5b6d8aeb2614c85beb49509714a063128bbbb2cc (patch)
treeb61e9ad44ae6cb3a06c28027caf9b48783b5f87b
parent478a8f37e3b6cf2a164a5027926b1393e9557dc4 (diff)
downloadopenvswitch-5b6d8aeb2614c85beb49509714a063128bbbb2cc.tar.gz
netdev: Safely increment refcount in netdev_open().
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 <joestringer@nicira.com> Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
-rw-r--r--lib/netdev.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index 5ed60624c..f1b7dbe9d 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -349,15 +349,15 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
error = 0;
}
- ovs_mutex_unlock(&netdev_mutex);
- ovs_rwlock_unlock(&netdev_class_rwlock);
-
if (!error) {
netdev->ref_cnt++;
*netdevp = netdev;
} else {
*netdevp = NULL;
}
+ ovs_mutex_unlock(&netdev_mutex);
+ ovs_rwlock_unlock(&netdev_class_rwlock);
+
return error;
}