From 14750a2e48f40d550f9fe7b1891d82a413ceef21 Mon Sep 17 00:00:00 2001 From: Sagar Nageshmurthy Date: Mon, 24 Nov 2014 18:11:40 +0530 Subject: [PATCH] audio/a2dp: Fix Access session device only when its valid session will be NULL if A2DP connection fails because of NO REPLY from endpoint or if the configuration is aborted. Accessing session device in such a scenario leads to bluetoothd crash. (gdb) bt full 0 avdtp_get_device (session=0x0) at profiles/audio/avdtp.c:3987 No locals. 1 0xb6f0e352 in auto_config (data=) at profiles/audio/a2dp.c:382 setup = 0xb7a4f230 dev = 2 0xb6f132f6 in config_cb (endpoint=, ret=, size=, user_data=) at profiles/audio/media.c:534 data = 3 0xb6f1398a in media_endpoint_cancel (endpoint=0xb7a43e78) at profiles/audio/media.c:136 endpoint = 0xb7a43e78 4 media_endpoint_cancel_all (endpoint=0xb7a43e78) at profiles/audio/media.c:144 No locals. 5 0xb6f13e04 in clear_endpoint (endpoint=0xb7a43e78) at profiles/audio/media.c:245 No locals. 6 0xb6f13f68 in endpoint_reply (call=, user_data=0xb7a4e538) at profiles/audio/media.c:275 request = 0xb7a4e538 endpoint = 0xb7a43e78 reply = 0xb7a3f560 err = {name = 0xb7a5de70 "org.freedesktop.DBus.Error.NoReply" --- profiles/audio/a2dp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index c9dac9a08..6b72f996e 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -379,7 +379,7 @@ static void stream_state_changed(struct avdtp_stream *stream, static gboolean auto_config(gpointer data) { struct a2dp_setup *setup = data; - struct btd_device *dev = avdtp_get_device(setup->session); + struct btd_device *dev = NULL; struct btd_service *service; /* Check if configuration was aborted */ @@ -389,6 +389,8 @@ static gboolean auto_config(gpointer data) if (setup->err != NULL) goto done; + dev = avdtp_get_device(setup->session); + avdtp_stream_add_cb(setup->session, setup->stream, stream_state_changed, setup->sep); -- 2.47.3