Bluetooth: Don't check source address in SCO bind function
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 19 Apr 2012 11:43:53 +0000 (13:43 +0200)
committerGustavo Padovan <gustavo@padovan.org>
Wed, 9 May 2012 04:40:38 +0000 (01:40 -0300)
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.

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

index 84d7a8023f80c5a944d7823f13e520b17cd524ba..c75cd7b07d18742fe5b55ba8596f214386e0640c 100644 (file)
@@ -462,7 +462,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));
@@ -477,17 +476,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);