From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v3 5/5] shared/bap: Protect bap_stream_notify_connecting
Date: Mon, 29 Jun 2026 10:27:38 -0400 [thread overview]
Message-ID: <20260629142738.966641-1-luiz.dentz@gmail.com> (raw)
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
reply other threads:[~2026-06-29 14:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629142738.966641-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox