Bluetooth: Do not dereference zero sk
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Tue, 14 Feb 2012 13:12:57 +0000 (15:12 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 16 Feb 2012 13:15:08 +0000 (15:15 +0200)
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
net/bluetooth/l2cap_sock.c

index 1636029..138fe34 100644 (file)
@@ -795,7 +795,7 @@ static void l2cap_sock_kill(struct sock *sk)
 static int l2cap_sock_shutdown(struct socket *sock, int how)
 {
        struct sock *sk = sock->sk;
-       struct l2cap_chan *chan = l2cap_pi(sk)->chan;
+       struct l2cap_chan *chan;
        int err = 0;
 
        BT_DBG("sock %p, sk %p", sock, sk);
@@ -803,6 +803,8 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
        if (!sk)
                return 0;
 
+       chan = l2cap_pi(sk)->chan;
+
        lock_sock(sk);
        if (!sk->sk_shutdown) {
                if (chan->mode == L2CAP_MODE_ERTM)