Skip to content

Commit 4a77708

Browse files
Luiz Augusto von DentzGustavo F. Padovan
authored andcommitted
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: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent d0fad89 commit 4a77708

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎net/bluetooth/sco.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,15 @@ static void __sco_sock_close(struct sock *sk)
369369

370370
case BT_CONNECTED:
371371
case BT_CONFIG:
372+
if (sco_pi(sk)->conn) {
373+
sk->sk_state = BT_DISCONN;
374+
sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
375+
hci_conn_put(sco_pi(sk)->conn->hcon);
376+
sco_pi(sk)->conn->hcon = NULL;
377+
} else
378+
sco_chan_del(sk, ECONNRESET);
379+
break;
380+
372381
case BT_CONNECT:
373382
case BT_DISCONN:
374383
sco_chan_del(sk, ECONNRESET);
@@ -819,7 +828,9 @@ static void sco_chan_del(struct sock *sk, int err)
819828
conn->sk = NULL;
820829
sco_pi(sk)->conn = NULL;
821830
sco_conn_unlock(conn);
822-
hci_conn_put(conn->hcon);
831+
832+
if (conn->hcon)
833+
hci_conn_put(conn->hcon);
823834
}
824835

825836
sk->sk_state = BT_CLOSED;

0 commit comments

Comments
 (0)