[PATCH BlueZ 3/4] A2DP: Fix not setting setup error to NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

Once the error is informed to the callback it should be properly freed and
set to NULL otherwise a subsequent operation may end up reusing the same
error which might lead to crashes.
---
 profiles/audio/a2dp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index efb4178..4b28465 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -366,16 +366,13 @@ static void stream_state_changed(struct avdtp_stream *stream,
 static gboolean auto_config(gpointer data)
 {
 	struct a2dp_setup *setup = data;
-	struct avdtp_error *err = NULL;
 
 	/* Check if configuration was aborted */
 	if (setup->sep->stream == NULL)
 		return FALSE;
 
-	if (setup->err != NULL) {
-		err = setup->err;
+	if (setup->err != NULL)
 		goto done;
-	}
 
 	avdtp_stream_add_cb(setup->session, setup->stream,
 				stream_state_changed, setup->sep);
@@ -391,8 +388,10 @@ done:
 
 	finalize_config(setup);
 
-	if (err)
-		g_free(err);
+	if (setup->err) {
+		g_free(setup->err);
+		setup->err = NULL;
+	}
 
 	setup_unref(setup);
 
@@ -565,6 +564,7 @@ static void setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 		if (setup) {
 			setup->err = err;
 			finalize_config(setup);
+			setup->err = NULL;
 		}
 		return;
 	}
-- 
1.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux