Skip to content

Commit

Permalink
net: sock_bindtodevice() RCU-ification
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 6, 2009
1 parent 69df9d5 commit bf8e56b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bf8e56b

Please sign in to comment.