Skip to contentSkip to conversation

audio/avdtp: Fix invalid reference counting

PATCH Applied Vinicius Costa Gomes 2 participants 2 messages Aug 20, 2014 – Aug 21, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 audio/avdtp: Fix invalid reference counting

If the AVDTP session is terminated via any other mean than 'connection_lost()' (the only place that btd_device_unref() was called), there was a dangling reference to the device.

This can be easily reproduced by suspending the host while using an A2DP speaker. It has the very misleading effect of being unable to create the device when the system resumes.

---
 profiles/audio/avdtp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
profiles/audio/avdtp.c +1 -1
index 8a7d1c0..ba5f0e5 100644
@@ -1135,6 +1135,7 @@ static void avdtp_free(void *data)
 
 	g_free(session->buf);
 
+	btd_device_unref(session->device);
 	g_free(session);
 }
 
@@ -1160,7 +1161,6 @@ static void connection_lost(struct avdtp *session, int err)
 		return;
 
 	server->sessions = g_slist_remove(server->sessions, session);
-	btd_device_unref(session->device);
 	avdtp_free(session);
 }
 
Signature · 1 line
2.0.4
maintainer Applied
#1 lore raw

Hi Vinicius,

Quoted 32 lines · Vinicius Costa Gomes

If the AVDTP session is terminated via any other mean than 'connection_lost()' (the only place that btd_device_unref() was called), there was a dangling reference to the device.

This can be easily reproduced by suspending the host while using an A2DP speaker. It has the very misleading effect of being unable to create the device when the system resumes.

---
 profiles/audio/avdtp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
profiles/audio/avdtp.c +1 -2
index 8a7d1c0..ba5f0e5 100644
@@ -1135,6 +1135,7 @@ static void avdtp_free(void *data)
 
        g_free(session->buf);
 
+       btd_device_unref(session->device);
        g_free(session);
 }
 
@@ -1160,7 +1161,6 @@ static void connection_lost(struct avdtp *session, int err)
                return;
 
        server->sessions = g_slist_remove(server->sessions, session);
-       btd_device_unref(session->device);
        avdtp_free(session);
 }
 
--
Quoted 1 line

2.0.4

Nice catch, Ive been hunting this very problem for some time.

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz