aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-11-06 00:03:39 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-06 01:34:24 -0500
commitbf8e56bfc4fcfcef9f08e6233dc619706807893a (patch)
tree9f676974aab7ee5e9eef8f81a62ea9b6408c5ed4 /net
parent69df9d5993bd7dd7499ad0e98fe824147fbe5667 (diff)
net: sock_bindtodevice() RCU-ification
Avoid dev_hold()/dev_put() in sock_bindtodevice() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/sock.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 5a51512f638a..38820eaecd43 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -420,14 +420,16 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
420 if (devname[0] == '\0') { 420 if (devname[0] == '\0') {
421 index = 0; 421 index = 0;
422 } else { 422 } else {
423 struct net_device *dev = dev_get_by_name(net, devname); 423 struct net_device *dev;
424 424
425 rcu_read_lock();
426 dev = dev_get_by_name_rcu(net, devname);
427 if (dev)
428 index = dev->ifindex;
429 rcu_read_unlock();
425 ret = -ENODEV; 430 ret = -ENODEV;
426 if (!dev) 431 if (!dev)
427 goto out; 432 goto out;
428
429 index = dev->ifindex;
430 dev_put(dev);
431 } 433 }
432 434
433 lock_sock(sk); 435 lock_sock(sk);