openvswitch: Fix race.
authorJarno Rajahalme <jrajahalme@nicira.com>
Sun, 16 Feb 2014 01:42:29 +0000 (17:42 -0800)
committerJesse Gross <jesse@nicira.com>
Sun, 16 Feb 2014 01:42:29 +0000 (17:42 -0800)
ovs_vport_cmd_dump() did rcu_read_lock() only after getting the
datapath, which could have been deleted in between.  Resolved by
taking rcu_read_lock() before the get_dp() call.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
net/openvswitch/datapath.c

index e42340d3f8207ba544efe9f4702c9c55fb14d40d..8601b320b443ba0a0dfdadb54f4fddf78a8308a7 100644 (file)
@@ -1762,11 +1762,12 @@ static int ovs_vport_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
        int bucket = cb->args[0], skip = cb->args[1];
        int i, j = 0;
 
+       rcu_read_lock();
        dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
-       if (!dp)
+       if (!dp) {
+               rcu_read_unlock();
                return -ENODEV;
-
-       rcu_read_lock();
+       }
        for (i = bucket; i < DP_VPORT_HASH_BUCKETS; i++) {
                struct vport *vport;