aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-02-15 20:42:29 -0500
committerJesse Gross <jesse@nicira.com>2014-02-15 20:42:29 -0500
commit42ee19e2939277a5277c307e517ce2d7ba5f0703 (patch)
tree57448c732f703451d3e7a96ff9e736ea62acd1dc
parent04382a3303c22b0c536fbd0c94c1f012f2b8ed60 (diff)
openvswitch: Fix race.
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>
-rw-r--r--net/openvswitch/datapath.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index e42340d3f820..8601b320b443 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1762,11 +1762,12 @@ static int ovs_vport_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1762 int bucket = cb->args[0], skip = cb->args[1]; 1762 int bucket = cb->args[0], skip = cb->args[1];
1763 int i, j = 0; 1763 int i, j = 0;
1764 1764
1765 rcu_read_lock();
1765 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex); 1766 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
1766 if (!dp) 1767 if (!dp) {
1768 rcu_read_unlock();
1767 return -ENODEV; 1769 return -ENODEV;
1768 1770 }
1769 rcu_read_lock();
1770 for (i = bucket; i < DP_VPORT_HASH_BUCKETS; i++) { 1771 for (i = bucket; i < DP_VPORT_HASH_BUCKETS; i++) {
1771 struct vport *vport; 1772 struct vport *vport;
1772 1773