Bluetooth: hci_conn: Fix sending BT_HCI_CMD_LE_CREATE_CONN_CANCEL
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 15 Aug 2023 21:15:05 +0000 (14:15 -0700)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 24 Aug 2023 19:20:16 +0000 (12:20 -0700)
This fixes sending BT_HCI_CMD_LE_CREATE_CONN_CANCEL when
hci_le_create_conn_sync has not been called because HCI_CONN_SCANNING
has been clear too early before its cmd_sync callback has been run.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_conn.c

index 2347467..9533962 100644 (file)
@@ -1299,6 +1299,7 @@ static int hci_connect_le_sync(struct hci_dev *hdev, void *data)
 
        bt_dev_dbg(hdev, "conn %p", conn);
 
+       clear_bit(HCI_CONN_SCANNING, &conn->flags);
        conn->state = BT_CONNECT;
 
        return hci_le_create_conn_sync(hdev, conn);
@@ -1370,8 +1371,6 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
        conn->sec_level = BT_SECURITY_LOW;
        conn->conn_timeout = conn_timeout;
 
-       clear_bit(HCI_CONN_SCANNING, &conn->flags);
-
        err = hci_cmd_sync_queue(hdev, hci_connect_le_sync,
                                 UINT_PTR(conn->handle),
                                 create_le_conn_complete);