aboutsummaryrefslogtreecommitdiffstats
path: root/net/caif/caif_socket.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-10-06 22:39:31 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-06 22:39:31 -0400
commit69259abb64d4da77273bf59accfc9fa79e7165f4 (patch)
treebd043ab03a788b749c8d5ae4049d8defae9abf34 /net/caif/caif_socket.c
parentdd53df265b1ee7a1fbbc76bb62c3bec2383bbd44 (diff)
parent12e94471b2be5ef9b55b10004a3a2cd819490036 (diff)
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.c17
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,
819 long timeo; 819 long timeo;
820 int err; 820 int err;
821 int ifindex, headroom, tailroom; 821 int ifindex, headroom, tailroom;
822 unsigned int mtu;
822 struct net_device *dev; 823 struct net_device *dev;
823 824
824 lock_sock(sk); 825 lock_sock(sk);
@@ -888,14 +889,22 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr,
888 cf_sk->sk.sk_state = CAIF_DISCONNECTED; 889 cf_sk->sk.sk_state = CAIF_DISCONNECTED;
889 goto out; 890 goto out;
890 } 891 }
891 dev = dev_get_by_index(sock_net(sk), ifindex); 892
893 err = -ENODEV;
894 rcu_read_lock();
895 dev = dev_get_by_index_rcu(sock_net(sk), ifindex);
896 if (!dev) {
897 rcu_read_unlock();
898 goto out;
899 }
892 cf_sk->headroom = LL_RESERVED_SPACE_EXTRA(dev, headroom); 900 cf_sk->headroom = LL_RESERVED_SPACE_EXTRA(dev, headroom);
901 mtu = dev->mtu;
902 rcu_read_unlock();
903
893 cf_sk->tailroom = tailroom; 904 cf_sk->tailroom = tailroom;
894 cf_sk->maxframe = dev->mtu - (headroom + tailroom); 905 cf_sk->maxframe = mtu - (headroom + tailroom);
895 dev_put(dev);
896 if (cf_sk->maxframe < 1) { 906 if (cf_sk->maxframe < 1) {
897 pr_warn("CAIF Interface MTU too small (%d)\n", dev->mtu); 907 pr_warn("CAIF Interface MTU too small (%d)\n", dev->mtu);
898 err = -ENODEV;
899 goto out; 908 goto out;
900 } 909 }
901 910