Skip to content

Commit d47da6b

Browse files
committed
Bluetooth: hci_core: Fix sending MGMT_EV_CONNECT_FAILED
If HCI_CONN_MGMT_CONNECTED has been set then the event shall be HCI_CONN_MGMT_DISCONNECTED. Fixes: b644ba3 ("Bluetooth: Update device_connected and device_found events to latest API") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 9a05709 commit d47da6b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,8 +2257,8 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
22572257
bool mgmt_connected);
22582258
void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
22592259
u8 link_type, u8 addr_type, u8 status);
2260-
void mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
2261-
u8 addr_type, u8 status);
2260+
void mgmt_connect_failed(struct hci_dev *hdev, struct hci_conn *conn,
2261+
u8 status);
22622262
void mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure);
22632263
void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
22642264
u8 status);

net/bluetooth/hci_conn.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ void hci_connect_le_scan_cleanup(struct hci_conn *conn, u8 status)
106106
* where a timeout + cancel does indicate an actual failure.
107107
*/
108108
if (status && status != HCI_ERROR_UNKNOWN_CONN_ID)
109-
mgmt_connect_failed(hdev, &conn->dst, conn->type,
110-
conn->dst_type, status);
109+
mgmt_connect_failed(hdev, conn, status);
111110

112111
/* The connection attempt was doing scan for new RPA, and is
113112
* in scan phase. If params are not associated with any other
@@ -1249,8 +1248,7 @@ void hci_conn_failed(struct hci_conn *conn, u8 status)
12491248
hci_le_conn_failed(conn, status);
12501249
break;
12511250
case ACL_LINK:
1252-
mgmt_connect_failed(hdev, &conn->dst, conn->type,
1253-
conn->dst_type, status);
1251+
mgmt_connect_failed(hdev, conn, status);
12541252
break;
12551253
}
12561254

net/bluetooth/mgmt.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9779,13 +9779,18 @@ void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
97799779
mgmt_pending_remove(cmd);
97809780
}
97819781

9782-
void mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
9783-
u8 addr_type, u8 status)
9782+
void mgmt_connect_failed(struct hci_dev *hdev, struct hci_conn *conn, u8 status)
97849783
{
97859784
struct mgmt_ev_connect_failed ev;
97869785

9787-
bacpy(&ev.addr.bdaddr, bdaddr);
9788-
ev.addr.type = link_to_bdaddr(link_type, addr_type);
9786+
if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) {
9787+
mgmt_device_disconnected(hdev, &conn->dst, conn->type,
9788+
conn->dst_type, status, true);
9789+
return;
9790+
}
9791+
9792+
bacpy(&ev.addr.bdaddr, &conn->dst);
9793+
ev.addr.type = link_to_bdaddr(conn->type, conn->dst_type);
97899794
ev.status = mgmt_status(status);
97909795

97919796
mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL);

0 commit comments

Comments
 (0)