From: Luiz Augusto von Dentz Date: Fri, 8 Apr 2011 14:10:41 +0000 (+0300) Subject: Bluetooth: fix shutdown on SCO sockets X-Git-Tag: v2.6.39-rc6~7^2~24^2~3^2~1 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=f21ca5fff6e548833fa5ee8867239a8378623150;p=~shefty%2Frdma-dev.git 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 Signed-off-by: Gustavo F. Padovan --- diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 42fdffd1d76..94954c74f6a 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 = NULL; + } else + sco_chan_del(sk, ECONNRESET); + break; + case BT_CONNECT: case BT_DISCONN: sco_chan_del(sk, ECONNRESET);