diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-04-22 21:58:18 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2022-04-26 20:10:51 +0200 |
commit | 9b3628d79b46f06157affc56fdb218fdd4988321 (patch) | |
tree | 1c73ca2c7218cac0ca4585be26d03aeb8a3596c1 /net/bluetooth/hci_sync.c | |
parent | Bluetooth: hci_event: Fix creating hci_conn object on error status (diff) | |
download | linux-9b3628d79b46f06157affc56fdb218fdd4988321.tar.xz linux-9b3628d79b46f06157affc56fdb218fdd4988321.zip |
Bluetooth: hci_sync: Cleanup hci_conn if it cannot be aborted
This attempts to cleanup the hci_conn if it cannot be aborted as
otherwise it would likely result in having the controller and host
stack out of sync with respect to connection handle.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_sync.c')
-rw-r--r-- | net/bluetooth/hci_sync.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 8f4c5698913d..13600bf120b0 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -4408,12 +4408,21 @@ static int hci_reject_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, static int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason) { + int err; + switch (conn->state) { case BT_CONNECTED: case BT_CONFIG: return hci_disconnect_sync(hdev, conn, reason); case BT_CONNECT: - return hci_connect_cancel_sync(hdev, conn); + err = hci_connect_cancel_sync(hdev, conn); + /* Cleanup hci_conn object if it cannot be cancelled as it + * likelly means the controller and host stack are out of sync. + */ + if (err) + hci_conn_failed(conn, err); + + return err; case BT_CONNECT2: return hci_reject_conn_sync(hdev, conn, reason); default: |