Skip to contentSkip to conversation

Bluetooth: Split error handling for L2CAP listen sockets

PATCH Applied Marcel Holtmann 2 participants 2 messages Apr 19, 2012

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 1/3 Bluetooth: Split error handling for L2CAP listen sockets

Split the checks for sk->sk_state and sk->sk_type for L2CAP listen sockets. This makes the code more readable.

---
 net/bluetooth/l2cap_sock.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_sock.c +6 -2
index 1463b5d..4d03b45 100644
@@ -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;
Signature · 1 line
1.7.7.6
#1 lore raw

Hi Marcel,

Quoted 7 lines · Marcel Holtmann

Split the checks for sk->sk_state and sk->sk_type for L2CAP listen sockets. This makes the code more readable.

---
 net/bluetooth/l2cap_sock.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Applied to bluetooth-next, thanks.

Gustavo