提交 bf8e56bf 编写于 作者: E Eric Dumazet 提交者: David S. Miller

net: sock_bindtodevice() RCU-ification

Avoid dev_hold()/dev_put() in sock_bindtodevice()
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 69df9d59
......@@ -420,14 +420,16 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
if (devname[0] == '\0') {
index = 0;
} else {
struct net_device *dev = dev_get_by_name(net, devname);
struct net_device *dev;
rcu_read_lock();
dev = dev_get_by_name_rcu(net, devname);
if (dev)
index = dev->ifindex;
rcu_read_unlock();
ret = -ENODEV;
if (!dev)
goto out;
index = dev->ifindex;
dev_put(dev);
}
lock_sock(sk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册