Commit 4a77708b authored by Luiz Augusto von Dentz's avatar Luiz Augusto von Dentz Committed by Gustavo F. Padovan

Bluetooth: fix shutdown on SCO sockets

shutdown should wait for SCO link to be properly disconnected before
detroying the socket, otherwise an application using the socket may
assume link is properly disconnected before it really happens which
can be a problem when e.g synchronizing profile switch.
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent d0fad89d
...@@ -369,6 +369,15 @@ static void __sco_sock_close(struct sock *sk) ...@@ -369,6 +369,15 @@ static void __sco_sock_close(struct sock *sk)
case BT_CONNECTED: case BT_CONNECTED:
case BT_CONFIG: case BT_CONFIG:
if (sco_pi(sk)->conn) {
sk->sk_state = BT_DISCONN;
sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
hci_conn_put(sco_pi(sk)->conn->hcon);
sco_pi(sk)->conn->hcon = NULL;
} else
sco_chan_del(sk, ECONNRESET);
break;
case BT_CONNECT: case BT_CONNECT:
case BT_DISCONN: case BT_DISCONN:
sco_chan_del(sk, ECONNRESET); sco_chan_del(sk, ECONNRESET);
...@@ -819,7 +828,9 @@ static void sco_chan_del(struct sock *sk, int err) ...@@ -819,7 +828,9 @@ static void sco_chan_del(struct sock *sk, int err)
conn->sk = NULL; conn->sk = NULL;
sco_pi(sk)->conn = NULL; sco_pi(sk)->conn = NULL;
sco_conn_unlock(conn); sco_conn_unlock(conn);
hci_conn_put(conn->hcon);
if (conn->hcon)
hci_conn_put(conn->hcon);
} }
sk->sk_state = BT_CLOSED; sk->sk_state = BT_CLOSED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment