diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-08-08 07:53:56 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-08-21 10:47:04 -0400 |
commit | 9d225d2208a6f17da5987ff4e7710b9e805cb5d6 (patch) | |
tree | ce01f5033eb9f4592e2e05f307d5eedc1b42fd6f /net/bluetooth/sco.c | |
parent | ba34dd3df73eaa2aa4fbb82a91aade3f3a910acb (diff) |
Bluetooth: Fix getting SCO socket options in deferred state
When a socket is in deferred state there does actually exist an
underlying connection even though the connection state is not yet
BT_CONNECTED. In the deferred state it should therefore be allowed to
get socket options that usually depend on a connection, such as
SCO_OPTIONS and SCO_CONNINFO.
This patch fixes the behavior of some user space code that behaves as
follows without it:
$ sudo tools/btiotest -i 00:1B:DC:xx:xx:xx -d -s
accept=2 reject=-1 discon=-1 defer=1 sec=0 update_sec=0 prio=0 voice=0x0000
Listening for SCO connections
bt_io_get(OPT_DEST): getsockopt(SCO_OPTIONS): Transport endpoint is not connected (107)
Accepting connection
Successfully connected to 60:D8:19:xx:xx:xx. handle=43, class=000000
The conditions that the patch updates the if-statements to is taken from
similar code in l2cap_sock.c which correctly handles the deferred state.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r-- | net/bluetooth/sco.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index e7bd4eea575c..2de7150a6304 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -765,7 +765,9 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user | |||
765 | 765 | ||
766 | switch (optname) { | 766 | switch (optname) { |
767 | case SCO_OPTIONS: | 767 | case SCO_OPTIONS: |
768 | if (sk->sk_state != BT_CONNECTED) { | 768 | if (sk->sk_state != BT_CONNECTED && |
769 | !(sk->sk_state == BT_CONNECT2 && | ||
770 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))) { | ||
769 | err = -ENOTCONN; | 771 | err = -ENOTCONN; |
770 | break; | 772 | break; |
771 | } | 773 | } |
@@ -781,7 +783,9 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user | |||
781 | break; | 783 | break; |
782 | 784 | ||
783 | case SCO_CONNINFO: | 785 | case SCO_CONNINFO: |
784 | if (sk->sk_state != BT_CONNECTED) { | 786 | if (sk->sk_state != BT_CONNECTED && |
787 | !(sk->sk_state == BT_CONNECT2 && | ||
788 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))) { | ||
785 | err = -ENOTCONN; | 789 | err = -ENOTCONN; |
786 | break; | 790 | break; |
787 | } | 791 | } |