diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 0795818963a..aa3607327ad 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1232,15 +1232,15 @@ void hci_conn_del(struct hci_conn *conn) skb_queue_purge(&conn->data_q); skb_queue_purge(&conn->tx_q.queue); + /* Dequeue callbacks using connection pointer as data */ + hci_cmd_sync_dequeue(hdev, NULL, conn, NULL); + /* Remove the connection from the list and cleanup its remaining * state. This is a separate function since for some cases like * BT_CONNECT_SCAN we *only* want the cleanup part without the * rest of hci_conn_del. */ hci_conn_cleanup(conn); - - /* Dequeue callbacks using connection pointer as data */ - hci_cmd_sync_dequeue(hdev, NULL, conn, NULL); } struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src, uint8_t src_type) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index f04a90bce4a..f31086c187f 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -7371,6 +7371,9 @@ static void le_read_features_complete(struct hci_dev *hdev, void *data, int err) if (err == -ECANCELED) return; + if (!hci_conn_valid(hdev, conn)) + return; + hci_conn_drop(conn); }