Bluetooth: Split error handling for L2CAP listen sockets
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 19 Apr 2012 11:43:51 +0000 (13:43 +0200)
committerGustavo Padovan <gustavo@padovan.org>
Wed, 9 May 2012 04:40:37 +0000 (01:40 -0300)
Split the checks for sk->sk_state and sk->sk_type for L2CAP listen
sockets. This makes the code more readable.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
net/bluetooth/l2cap_sock.c

index 46126cbc9de438251e9939cf80257760a452f362..8d8b50a29906d44b5e4ce19e5e98e67b0a4ee8f0 100644 (file)
@@ -148,12 +148,16 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
 
        lock_sock(sk);
 
-       if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM)
-                       || sk->sk_state != BT_BOUND) {
+       if (sk->sk_state != BT_BOUND) {
                err = -EBADFD;
                goto done;
        }
 
+       if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM) {
+               err = -EINVAL;
+               goto done;
+       }
+
        switch (chan->mode) {
        case L2CAP_MODE_BASIC:
                break;