* [PATCH v2] avdtp: Fix use-after-free in connection_lost
@ 2026-10-16 7:14 Jinwang Li
2026-10-16 11:35 ` [v2] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Jinwang Li @ 2026-10-16 7:14 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
Cc: cheng.jiang, quic_chezhou, wei.deng, shuai.zhang, mengshi.wu,
jinwang.li, xiuzhuo.shang
release_stream() may free the session's a2dp_setup through
abort_cfm(). Subsequently, finalize_discovery() passes the same
freed a2dp_setup to discover_cb(), resulting in a use-after-free.
Call finalize_discovery() before release_stream() instead.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Jinwang Li <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 56d27b973..b8d9b8e94 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -1158,11 +1158,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-10-16 11:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 7:14 [PATCH v2] avdtp: Fix use-after-free in connection_lost Jinwang Li
2026-10-16 11:35 ` [v2] " 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