summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2011-05-12 11:13:15 +0300
committerGustavo F. Padovan <padovan@profusion.mobi>2011-06-10 15:04:40 -0300
commit0da67bed835fdde68ca0e924d2a2d6ac82c70833 (patch)
tree99764bd69e391568fd1b43dc90f20ea6493cc354
parent8d03e971cf403305217b8e62db3a2e5ad2d6263f (diff)
downloadkernel-uprobes-0da67bed835fdde68ca0e924d2a2d6ac82c70833.tar.gz
kernel-uprobes-0da67bed835fdde68ca0e924d2a2d6ac82c70833.tar.xz
kernel-uprobes-0da67bed835fdde68ca0e924d2a2d6ac82c70833.zip
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>
-rw-r--r--net/bluetooth/sco.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 42fdffd1d76..cb4fb7837e5 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -369,6 +369,15 @@ static void __sco_sock_close(struct sock *sk)
case BT_CONNECTED:
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_DISCONN:
sco_chan_del(sk, ECONNRESET);
@@ -819,7 +828,9 @@ static void sco_chan_del(struct sock *sk, int err)
conn->sk = NULL;
sco_pi(sk)->conn = NULL;
sco_conn_unlock(conn);
- hci_conn_put(conn->hcon);
+
+ if (conn->hcon)
+ hci_conn_put(conn->hcon);
}
sk->sk_state = BT_CLOSED;