diff options
author | David S. Miller <davem@davemloft.net> | 2010-10-07 04:39:31 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-07 04:39:31 +0200 |
commit | 69259abb64d4da77273bf59accfc9fa79e7165f4 (patch) | |
tree | bd043ab03a788b749c8d5ae4049d8defae9abf34 /net/caif/caif_socket.c | |
parent | bonding: add Speed/Duplex information to /proc/net/bonding/bond (diff) | |
parent | Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds... (diff) | |
download | linux-69259abb64d4da77273bf59accfc9fa79e7165f4.tar.xz linux-69259abb64d4da77273bf59accfc9fa79e7165f4.zip |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts:
drivers/net/pcmcia/pcnet_cs.c
net/caif/caif_socket.c
Diffstat (limited to 'net/caif/caif_socket.c')
-rw-r--r-- | net/caif/caif_socket.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index abcba5358b63..2eca2dd0000f 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c @@ -819,6 +819,7 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr, long timeo; int err; int ifindex, headroom, tailroom; + unsigned int mtu; struct net_device *dev; lock_sock(sk); @@ -888,14 +889,22 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr, cf_sk->sk.sk_state = CAIF_DISCONNECTED; goto out; } - dev = dev_get_by_index(sock_net(sk), ifindex); + + err = -ENODEV; + rcu_read_lock(); + dev = dev_get_by_index_rcu(sock_net(sk), ifindex); + if (!dev) { + rcu_read_unlock(); + goto out; + } cf_sk->headroom = LL_RESERVED_SPACE_EXTRA(dev, headroom); + mtu = dev->mtu; + rcu_read_unlock(); + cf_sk->tailroom = tailroom; - cf_sk->maxframe = dev->mtu - (headroom + tailroom); - dev_put(dev); + cf_sk->maxframe = mtu - (headroom + tailroom); if (cf_sk->maxframe < 1) { pr_warn("CAIF Interface MTU too small (%d)\n", dev->mtu); - err = -ENODEV; goto out; } |