Bluetooth: Split error handling for SCO listen sockets
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 19 Apr 2012 11:43:52 +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 SCO 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/sco.c

index 7bd0947af2fa7309d18e8460fdc03bd976aab8f6..a69aa345597e77d2cd34cdf443702acccbb4b318 100644 (file)
@@ -539,11 +539,16 @@ static int sco_sock_listen(struct socket *sock, int backlog)
 
        lock_sock(sk);
 
-       if (sk->sk_state != BT_BOUND || sock->type != SOCK_SEQPACKET) {
+       if (sk->sk_state != BT_BOUND) {
                err = -EBADFD;
                goto done;
        }
 
+       if (sk->sk_type != SOCK_SEQPACKET) {
+               err = -EINVAL;
+               goto done;
+       }
+
        sk->sk_max_ack_backlog = backlog;
        sk->sk_ack_backlog = 0;
        sk->sk_state = BT_LISTEN;