* [PATCH BlueZ v4] avdtp: Fix use-after-free in connection_lost
@ 2026-11-16 9:07 Jinwang Li
2026-11-16 21:48 ` [BlueZ,v4] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Jinwang Li @ 2026-11-16 9:07 UTC (permalink / raw)
To: linux-bluetooth
Cc: cheng.jiang, wei.deng, shuai.zhang, jinwang.li, xiuzhuo.shang
A sink may start reverse discovery when processing a remote stream
configuration. If the signaling channel disconnects after the stream is
configured and discovery holds the last setup reference, stream cleanup
frees that setup before the pending discovery callback runs, causing a
use-after-free.
Complete discovery with the disconnect error before releasing streams
so the callback runs while its setup is still valid.
Fixes: 02877c5e98b8 ("a2dp: Add reverse discovery")
Assisted-by: Claude:claude-sonnet-5
---
Changes for V4:
- Rebased the patch.
- Add Fixes tag.
- V3 link
https://lore.kernel.org/all/20261104073210.3995738-1-jinwang.li@oss.qualcomm.com/
Changes for V3:
- Update commit message.
- V2 link
https://lore.kernel.org/all/20261016071408.2961576-1-jinwang.li@oss.qualcomm.com/
Changes for V2:
- Rebased the patch.
- V1 link
https://lore.kernel.org/all/20260807095809.2584501-1-jinwang.li@oss.qualcomm.com/
---
profiles/audio/avdtp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 30f80a0c2..5ebc0c5cc 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -1159,11 +1159,11 @@ static void connection_lost(struct avdtp *session, int err)
ba2str(device_get_address(session->device), address);
DBG("Disconnected from %s", address);
+ finalize_discovery(session, err);
+
g_slist_foreach(session->streams, (GFunc) release_stream, session);
session->streams = NULL;
- finalize_discovery(session, err);
-
avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
avdtp_unref(session);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-16 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 9:07 [PATCH BlueZ v4] avdtp: Fix use-after-free in connection_lost Jinwang Li
2026-11-16 21:48 ` [BlueZ,v4] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox