Skip to content

Commit

Permalink
Bluetooth: hci_sync: hold hdev->lock when cleanup hci_conn
Browse files Browse the repository at this point in the history
When disconnecting all devices, hci_conn_failed is used to cleanup
hci_conn object when the hci_conn object cannot be aborted.
The function hci_conn_failed requires the caller holds hdev->lock.

Fixes: 9b3628d ("Bluetooth: hci_sync: Cleanup hci_conn if it cannot be aborted")
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Zhengping Jiang authored and Luiz Augusto von Dentz committed Aug 25, 2022
1 parent a112ff2 commit b828854
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/bluetooth/hci_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -5034,9 +5034,11 @@ int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason)
/* Cleanup hci_conn object if it cannot be cancelled as it
* likelly means the controller and host stack are out of sync.
*/
if (err)
if (err) {
hci_dev_lock(hdev);
hci_conn_failed(conn, err);

hci_dev_unlock(hdev);
}
return err;
case BT_CONNECT2:
return hci_reject_conn_sync(hdev, conn, reason);
Expand Down

0 comments on commit b828854

Please sign in to comment.