All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] audio/avdtp: Fix invalid reference counting
@ 2014-08-20 14:06 Vinicius Costa Gomes
  2014-08-21  7:54 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Vinicius Costa Gomes @ 2014-08-20 14:06 UTC (permalink / raw)
  To: linux-bluetooth

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(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 8a7d1c0..ba5f0e5 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -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);
 }
 
-- 
2.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] audio/avdtp: Fix invalid reference counting
  2014-08-20 14:06 [PATCH] audio/avdtp: Fix invalid reference counting Vinicius Costa Gomes
@ 2014-08-21  7:54 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2014-08-21  7:54 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth

Hi Vinicius,

On Wed, Aug 20, 2014 at 5:06 PM, Vinicius Costa Gomes <vcgomes@gmail.com> wrote:
> 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(-)
>
> diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
> index 8a7d1c0..ba5f0e5 100644
> --- a/profiles/audio/avdtp.c
> +++ b/profiles/audio/avdtp.c
> @@ -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);
>  }
>
> --
> 2.0.4

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

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-21  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 14:06 [PATCH] audio/avdtp: Fix invalid reference counting Vinicius Costa Gomes
2014-08-21  7:54 ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.