Commit 0da67bed835fdde68ca0e924d2a2d6ac82c70833

Authored by Luiz Augusto von Dentz
Committed by Gustavo F. Padovan
1 parent 8d03e971cf

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>

Showing 1 changed file with 12 additions and 1 deletions Side-by-side Diff

... ... @@ -369,6 +369,15 @@
369 369  
370 370 case BT_CONNECTED:
371 371 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 +
372 381 case BT_CONNECT:
373 382 case BT_DISCONN:
374 383 sco_chan_del(sk, ECONNRESET);
... ... @@ -819,7 +828,9 @@
819 828 conn->sk = NULL;
820 829 sco_pi(sk)->conn = NULL;
821 830 sco_conn_unlock(conn);
822   - hci_conn_put(conn->hcon);
  831 +
  832 + if (conn->hcon)
  833 + hci_conn_put(conn->hcon);
823 834 }
824 835  
825 836 sk->sk_state = BT_CLOSED;