Skip to contentSkip to conversation

Bluetooth: Don't check source address in SCO bind function

PATCH Applied Marcel Holtmann 2 participants 4 messages Apr 19, 2012 – Apr 20, 2012

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 3/3 Bluetooth: Don't check source address in SCO bind function

Checking the source address in SCO bind function will prevent from having an incoming and outgoing SCO socket. However that might be needed in case of multiple SCO connections on a single device.

---
 net/bluetooth/sco.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
net/bluetooth/sco.c +6 -10
index 2fb9636..8b2548c 100644
@@ -463,7 +463,6 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 {
 	struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
 	struct sock *sk = sock->sk;
-	bdaddr_t *src = &sa->sco_bdaddr;
 	int err = 0;
 
 	BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));
@@ -478,17 +477,14 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 		goto done;
 	}
 
-	write_lock(&sco_sk_list.lock);
-
-	if (bacmp(src, BDADDR_ANY) && __sco_get_sock_by_addr(src)) {
-		err = -EADDRINUSE;
-	} else {
-		/* Save source address */
-		bacpy(&bt_sk(sk)->src, &sa->sco_bdaddr);
-		sk->sk_state = BT_BOUND;
+	if (sk->sk_type != SOCK_SEQPACKET) {
+		err = -EINVAL;
+		goto done;
 	}
 
-	write_unlock(&sco_sk_list.lock);
+	bacpy(&bt_sk(sk)->src, &sa->sco_bdaddr);
+
+	sk->sk_state = BT_BOUND;
 
 done:
 	release_sock(sk);
Signature · 1 line
1.7.7.6
#1 lore raw

Hi Marcel,

net/bluetooth/sco.c static int sco_sock_bind(struct socket *sock, struct =

Quoted 14 lines · Marcel Holtmann

Checking the source address in SCO bind function will prevent from having an incoming and outgoing SCO socket. However that might be needed in case of multiple SCO connections on a single device. =20

---
 net/bluetooth/sco.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

=20

net/bluetooth/sco.c +0 -0
index 2fb9636..8b2548c 100644
@@ -463,7 +463,6 @@ static int sco_sock_bind(struct socket *sock, struct =

sockaddr *addr, int addr_le

net/bluetooth/sco.c static int sco_sock_bind(struct socket *sock, struc=

Quoted 8 lines
net/bluetooth/sco.c +0 -1
 {
 	struct sockaddr_sco *sa =3D (struct sockaddr_sco *) addr;
 	struct sock *sk =3D sock->sk;
-	bdaddr_t *src =3D &sa->sco_bdaddr;
 	int err =3D 0;

=20

net/bluetooth/sco.c +0 -0
 	BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));
@@ -478,17 +477,14 @@ static int sco_sock_bind(struct socket *sock, struc=

t sockaddr *addr, int addr_le

net/bluetooth/sco.c static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le

Quoted 7 lines
net/bluetooth/sco.c +0 -0
 		goto done;
 	}

=20

net/bluetooth/sco.c +0 -4
-	write_lock(&sco_sk_list.lock);
-
-	if (bacmp(src, BDADDR_ANY) && __sco_get_sock_by_addr(src)) {
-		err =3D -EADDRINUSE;

this patch adds a compiling warning:

CC [M] net/bluetooth/sco.o
net/bluetooth/sco.c:277:21: warning: =E2=80=98__sco_get_sock_by_addr=E2=
=80=99 defined
but not used [-Wunused-function]

Gustavo

author maintainer
#2 lore raw

Hi Gustavo,

Quoted 34 lines · Marcel Holtmann
Quoted 23 lines

Checking the source address in SCO bind function will prevent from having an incoming and outgoing SCO socket. However that might be needed in case of multiple SCO connections on a single device.

---
 net/bluetooth/sco.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
net/bluetooth/sco.c +0 -1
index 2fb9636..8b2548c 100644
@@ -463,7 +463,6 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 {
 	struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
 	struct sock *sk = sock->sk;
-	bdaddr_t *src = &sa->sco_bdaddr;
 	int err = 0;
 
 	BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));

net/bluetooth/sco.c static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le · line 484

Quoted 7 lines
net/bluetooth/sco.c +0 -4
@@ -478,17 +477,14 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 		goto done;
 	}
 
-	write_lock(&sco_sk_list.lock);
-
-	if (bacmp(src, BDADDR_ANY) && __sco_get_sock_by_addr(src)) {
-		err = -EADDRINUSE;

this patch adds a compiling warning:

Quoted 3 lines

CC [M] net/bluetooth/sco.o
net/bluetooth/sco.c:277:21: warning: ‘__sco_get_sock_by_addr’ defined but not used [-Wunused-function]

I am fixing that with the next patch. I just ended up splitting them into two to get this logical correct.

Regards

Marcel

#3 lore raw
In reply to Marcel Holtmann

Hi Marcel,

Quoted 8 lines · Marcel Holtmann

Checking the source address in SCO bind function will prevent from having an incoming and outgoing SCO socket. However that might be needed in case of multiple SCO connections on a single device.

---
 net/bluetooth/sco.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

Patch has been applied. Thanks.

Gustavo