All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vcgomes@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] audio/avdtp: Fix invalid reference counting
Date: Wed, 20 Aug 2014 11:06:52 -0300	[thread overview]
Message-ID: <1408543612-5615-1-git-send-email-vcgomes@gmail.com> (raw)

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


             reply	other threads:[~2014-08-20 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 14:06 Vinicius Costa Gomes [this message]
2014-08-21  7:54 ` [PATCH] audio/avdtp: Fix invalid reference counting Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408543612-5615-1-git-send-email-vcgomes@gmail.com \
    --to=vcgomes@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.