Skip to content

Commit 151e93b

Browse files
Vudentznashif
authored andcommitted
Bluetooth: ISO: Fix not calling channel disconnected
When the channel has just been bound but is not connected yet there is no need to send any command over the air but the disconnected callback shall still be called in order to notify the channel owner that it has reached disconnected state. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 84811d5 commit 151e93b

File tree

1 file changed

+21
-13
lines changed
  • subsys/bluetooth/host

1 file changed

+21
-13
lines changed

subsys/bluetooth/host/iso.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,25 @@ static void bt_iso_remove_data_path(struct bt_conn *conn)
734734
hci_le_remove_iso_data_path(conn, BT_HCI_DATAPATH_DIR_HOST_TO_CTLR);
735735
}
736736

737+
static void bt_iso_chan_del(struct bt_iso_chan *chan)
738+
{
739+
BT_DBG("%p", chan);
740+
741+
if (!chan->conn) {
742+
goto done;
743+
}
744+
745+
if (chan->ops->disconnected) {
746+
chan->ops->disconnected(chan);
747+
}
748+
749+
bt_conn_unref(chan->conn);
750+
chan->conn = NULL;
751+
752+
done:
753+
bt_iso_chan_set_state(chan, BT_ISO_DISCONNECTED);
754+
}
755+
737756
void bt_iso_disconnected(struct bt_conn *conn)
738757
{
739758
struct bt_iso_chan *chan, *next;
@@ -749,16 +768,7 @@ void bt_iso_disconnected(struct bt_conn *conn)
749768
bt_iso_remove_data_path(conn);
750769

751770
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&conn->channels, chan, next, node) {
752-
if (chan->ops->disconnected) {
753-
chan->ops->disconnected(chan);
754-
}
755-
756-
if (chan->conn) {
757-
bt_conn_unref(chan->conn);
758-
chan->conn = NULL;
759-
}
760-
761-
bt_iso_chan_set_state(chan, BT_ISO_DISCONNECTED);
771+
bt_iso_chan_del(chan);
762772
}
763773
}
764774

@@ -943,10 +953,8 @@ int bt_iso_chan_disconnect(struct bt_iso_chan *chan)
943953
}
944954

945955
if (chan->state == BT_ISO_BOUND) {
946-
bt_iso_chan_set_state(chan, BT_ISO_DISCONNECTED);
947956
bt_iso_chan_remove(chan->conn, chan);
948-
bt_conn_unref(chan->conn);
949-
chan->conn = NULL;
957+
bt_iso_chan_del(chan);
950958
return 0;
951959
}
952960

0 commit comments

Comments
 (0)