Skip to contentSkip to conversation

bluetooth: fix shutdown on SCO sockets

PATCH Applied Luiz Augusto von Dentz 2 participants 2 messages May 12, 2011 – May 19, 2011

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 bluetooth: fix shutdown on SCO sockets

From: Luiz Augusto von Dentz <[email protected]>

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.

---
 net/bluetooth/sco.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
net/bluetooth/sco.c +12 -1
index 42fdffd..cb4fb78 100644
@@ -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;
Signature · 1 line
1.7.1
#1 lore raw

Hi Luiz,

Quoted 11 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

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.

---
 net/bluetooth/sco.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

Applied, thanks.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi