Skip to content

Commit

Permalink
Bluetooth: Free potentially unfreed SCO connection
Browse files Browse the repository at this point in the history
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 <apusaka@chromium.org>
Reviewed-by: Ying Hsu <yinghsu@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
apusaka authored and Vudentz committed Feb 9, 2023
1 parent 03b0093 commit 0f00cd3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,15 @@ int hci_conn_del(struct hci_conn *conn)

if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
if (sco)
if (sco) {
sco->link = NULL;
/* Due to race, SCO connection might be not established
* yet at this point. Delete it now, otherwise it is
* possible for it to be stuck and can't be deleted.
*/
if (sco->handle == HCI_CONN_HANDLE_UNSET)
hci_conn_del(sco);
}

/* Unacked frames */
hdev->acl_cnt += conn->sent;
Expand Down

0 comments on commit 0f00cd3

Please sign in to comment.