From: Jarno Rajahalme Date: Tue, 11 Feb 2014 23:34:39 +0000 (-0800) Subject: datapath: Fix race. X-Git-Tag: sliver-openvswitch-2.1.90-1~1^2~59 X-Git-Url: http://git.onelab.eu/?p=sliver-openvswitch.git;a=commitdiff_plain;h=03fc2881382a9936f898e08d38bd8d623497409e datapath: 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 Signed-off-by: Pravin B Shelar --- diff --git a/datapath/datapath.c b/datapath/datapath.c index d528ba00c..edbbb884b 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1767,11 +1767,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;