@@ -1136,8 +1136,15 @@ static void hci_conn_unlink(struct hci_conn *conn)
void hci_conn_free(struct hci_conn *conn)
{
+ struct l2cap_conn *lcon = conn->l2cap_data;
+
BT_DBG("kfree(conn %p)", conn);
+ if (lcon && lcon->hcon == conn) {
+ BT_DBG("conn %p conn->l2cap_data->hcon = NULL", conn);
+ lcon->hcon = NULL;
+ }
+
kfree(conn);
}
@@ -1949,6 +1949,11 @@ static void l2cap_conn_free(struct kref *ref)
BT_DBG("kfree(conn) %p", conn);
+ if (conn->hcon && conn->hcon->l2cap_data == conn) {
+ BT_DBG("conn %p conn->hcon->l2cap_data = NULL", conn);
+ conn->hcon->l2cap_data = NULL;
+ }
+
hci_conn_put(conn->hcon);
kfree(conn);
}