Skip to content

Commit

Permalink
Bluetooth: Split error handling for L2CAP listen sockets
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marcel Holtmann authored and Gustavo Padovan committed May 9, 2012
1 parent 35d4adc commit 6b3af73
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/bluetooth/l2cap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6b3af73

Please sign in to comment.