diff options
author | Joe Stringer <joestringer@nicira.com> | 2014-05-02 11:55:05 +1200 |
---|---|---|
committer | Joe Stringer <joestringer@nicira.com> | 2014-05-05 12:21:13 +1200 |
commit | 5b6d8aeb2614c85beb49509714a063128bbbb2cc (patch) | |
tree | b61e9ad44ae6cb3a06c28027caf9b48783b5f87b | |
parent | 478a8f37e3b6cf2a164a5027926b1393e9557dc4 (diff) | |
download | openvswitch-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.c | 6 |
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; } |