Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v3 5/5] shared/bap: Protect bap_stream_notify_connecting
@ 2026-06-29 14:27 Luiz Augusto von Dentz
  0 siblings, 0 replies; only message in thread
From: Luiz Augusto von Dentz @ 2026-06-29 14:27 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

bap_stream_notify_connecting may encounter callbacks that remove itself
while traversing the state_cbs, so this attempts to prevent to cause a
crash by prefetching the next entry.
---
 src/shared/bap.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 7bcf28bcefe4..1f61227f82a7 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -3036,10 +3036,14 @@ static void bap_stream_notify_connecting(struct bt_bap_stream *stream,
 {
 	const struct queue_entry *entry;
 
-	for (entry = queue_get_entries(stream->bap->state_cbs); entry;
-						entry = entry->next) {
+	for (entry = queue_get_entries(stream->bap->state_cbs); entry;) {
 		struct bt_bap_state *state = entry->data;
 
+		/* Prefetch next entry since the callback may remove the current
+		 * entry.
+		 */
+		entry = entry->next;
+
 		if (state->connecting)
 			state->connecting(stream, connecting, fd, state->data);
 	}
-- 
2.54.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-29 14:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 14:27 [PATCH BlueZ v3 5/5] shared/bap: Protect bap_stream_notify_connecting Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox