Skip to content

Commit 5076476

Browse files
Thalleystephanosio
authored andcommitted
Bluetooth: BAP: Fix missing remove of streams from slist
In the broadcast sink when the streams disconnected (without the PA disconnecting), the streams were not properly removed from the sink's list of streams. This allowed the same stream to be added to the list twice, which would cause a infinite loop as the stream would point to itself as the next. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 6cefad3 commit 5076476

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

subsys/bluetooth/audio/bap_broadcast_sink.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ static void broadcast_sink_iso_disconnected(struct bt_iso_chan *chan,
347347
struct bt_bap_stream *stream;
348348
struct bt_bap_ep *ep = iso->rx.ep;
349349
struct bt_bap_broadcast_sink *sink;
350-
bool all_disconnected;
351350

352351
if (ep == NULL) {
353352
LOG_ERR("iso %p not bound with ep", chan);
@@ -378,17 +377,12 @@ static void broadcast_sink_iso_disconnected(struct bt_iso_chan *chan,
378377
return;
379378
}
380379

381-
all_disconnected = true;
382-
SYS_SLIST_FOR_EACH_CONTAINER(&sink->streams, stream, _node) {
383-
/* stream->ep is cleared when the steam disconnects */
384-
if (stream->ep != NULL) {
385-
all_disconnected = false;
386-
break;
387-
}
380+
if (!sys_slist_find_and_remove(&sink->streams, &stream->_node)) {
381+
LOG_DBG("Could not find and remove stream %p from sink %p", stream, sink);
388382
}
389383

390384
/* Clear sink->big if not already cleared */
391-
if (all_disconnected && sink->big) {
385+
if (sys_slist_is_empty(&sink->streams) && sink->big) {
392386
broadcast_sink_clear_big(sink, reason);
393387
}
394388
}

0 commit comments

Comments
 (0)