Skip to content

Commit 0f00cd3

Browse files
apusakaVudentz
authored andcommitted
Bluetooth: Free potentially unfreed SCO connection
It is possible to initiate a SCO connection while deleting the corresponding ACL connection, e.g. in below scenario: (1) < hci setup sync connect command (2) > hci disconn complete event (for the acl connection) (3) > hci command complete event (for(1), failure) When it happens, hci_cs_setup_sync_conn won't be able to obtain the reference to the SCO connection, so it will be stuck and potentially hinder subsequent connections to the same device. This patch prevents that by also deleting the SCO connection if it is still not established when the corresponding ACL connection is deleted. Signed-off-by: Archie Pusaka <[email protected]> Reviewed-by: Ying Hsu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 03b0093 commit 0f00cd3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

net/bluetooth/hci_conn.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,15 @@ int hci_conn_del(struct hci_conn *conn)
10611061

10621062
if (conn->type == ACL_LINK) {
10631063
struct hci_conn *sco = conn->link;
1064-
if (sco)
1064+
if (sco) {
10651065
sco->link = NULL;
1066+
/* Due to race, SCO connection might be not established
1067+
* yet at this point. Delete it now, otherwise it is
1068+
* possible for it to be stuck and can't be deleted.
1069+
*/
1070+
if (sco->handle == HCI_CONN_HANDLE_UNSET)
1071+
hci_conn_del(sco);
1072+
}
10661073

10671074
/* Unacked frames */
10681075
hdev->acl_cnt += conn->sent;

0 commit comments

Comments
 (0)