diff mbox series

[BlueZ,6/6] bass: Free stream path

Message ID 20250307154457.85751-7-iulia.tanasescu@nxp.com
State New
Headers show
Series bap: Remove interface | expand

Commit Message

Iulia Tanasescu March 7, 2025, 3:44 p.m. UTC
This frees BASS setup paths, to avoid memory leaks like below:

==5877==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 43 byte(s) in 1 object(s) allocated from:
    0x7ab1adefd9c7 in malloc ../../../../src/libsanitizer/asan/
                                        asan_malloc_linux.cpp:69
    0x7ab1ad08f937 in __vasprintf_internal libio/vasprintf.c:116
    0x7ab1ad135d62 in ___asprintf_chk debug/asprintf_chk.c:34
    0x5c2197401338 in asprintf /usr/include/x86_64-linux-gnu/bits/
                                                      stdio2.h:137
    0x5c2197401338 in setup_configure_stream profiles/audio/bass.c:420
---
 profiles/audio/bass.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c
index d987987ff..d299791c8 100644
--- a/profiles/audio/bass.c
+++ b/profiles/audio/bass.c
@@ -116,6 +116,7 @@  struct bass_delegator {
 
 struct bass_setup {
 	struct bass_delegator *dg;
+	char *path;
 	struct bt_bap_stream *stream;
 	uint8_t bis;
 	struct bt_bap_qos qos;
@@ -411,19 +412,17 @@  static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
 
 static void setup_configure_stream(struct bass_setup *setup)
 {
-	char *path;
-
 	setup->stream = bt_bap_stream_new(setup->dg->bap, setup->lpac, NULL,
 					&setup->qos, setup->config);
 	if (!setup->stream)
 		return;
 
-	if (asprintf(&path, "%s/bis%d",
+	if (asprintf(&setup->path, "%s/bis%d",
 			device_get_path(setup->dg->device),
 			setup->bis) < 0)
 		return;
 
-	bt_bap_stream_set_user_data(setup->stream, path);
+	bt_bap_stream_set_user_data(setup->stream, setup->path);
 
 	bt_bap_stream_config(setup->stream, &setup->qos,
 			setup->config, NULL, NULL);
@@ -649,6 +648,7 @@  static void setup_free(void *data)
 	util_iov_free(setup->qos.bcast.bcode, 1);
 	util_iov_free(setup->meta, 1);
 	util_iov_free(setup->config, 1);
+	free(setup->path);
 
 	/* Clear bis index from the bis sync bitmask, if it
 	 * has been previously set.