From cdcdfb4843b485e08f6a1460b5a03a3420453a51 Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Fri, 16 May 2025 17:49:20 -0400
Subject: a2dp: Fix not destroying streams when unregistering

When a2dp_unregister_sep it must destroy the stream queue before freeing
the a2dp_sep otherwise it will cause memory leaks.
---
 profiles/audio/a2dp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 482de4a987..7c0f9c54a9 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -565,8 +565,10 @@ static void a2dp_stream_starting(struct a2dp_sep *sep, struct avdtp *session)
 	stream->starting = TRUE;
 }
 
-static void a2dp_stream_free(struct a2dp_stream *stream)
+static void a2dp_stream_free(void *data)
 {
+	struct a2dp_stream *stream = data;
+
 	avdtp_unref(stream->session);
 	free(stream);
 }
@@ -2725,6 +2727,7 @@ static void a2dp_unregister_sep(struct a2dp_sep *sep)
 
 	avdtp_unregister_sep(server->seps, &server->seid_pool, sep->lsep);
 
+	queue_destroy(sep->streams, a2dp_stream_free);
 	g_free(sep);
 
 	if (!queue_isempty(server->seps))
-- 
cgit 1.2.3-korg

