Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 6/7] audio/AVCTP: Fix connecting browsing channel multiple times
Date: Mon, 29 Jul 2013 17:04:38 +0300	[thread overview]
Message-ID: <1375106679-14645-6-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1375106679-14645-1-git-send-email-luiz.dentz@gmail.com>

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

While accepting the connection via DEFER_SETUP a second connection can
be created by using avctp_connect_browsing which will not detect one is
in course as the state has not yet changed, this can cause memory leaks
or crashes as the following:

profiles/audio/avctp.c:avctp_confirm_cb() AVCTP: incoming connect from XX:XX:XX:XX:XX:XX
profiles/audio/avctp.c:avctp_set_state() AVCTP Browsing Connecting
profiles/audio/avctp.c:avctp_connect_browsing_cb() AVCTP Browsing: connected to XX:XX:XX:XX:XX:XX
profiles/audio/avctp.c:avctp_set_state() AVCTP Browsing Connected
profiles/audio/avctp.c:avctp_connect_browsing_cb() AVCTP Browsing: connected to XX:XX:XX:XX:XX:XX
profiles/audio/avctp.c:avctp_set_state() AVCTP Browsing Connected
profiles/audio/avctp.c:session_browsing_cb() AVCTP Browsing: disconnected
profiles/audio/avctp.c:avctp_set_state() AVCTP Connected
Invalid read of size 8
   at 0x41EB28: session_browsing_cb (avctp.c:842)
   by 0x32F5447E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x32F5448157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x32F5448559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40A28F: main (main.c:583)
 Address 0x20 is not stack'd, malloc'd or (recently) free'd
---
 profiles/audio/avctp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 11e9365..2c1aa94 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1328,8 +1328,10 @@ static void avctp_browsing_confirm(struct avctp *session, GIOChannel *chan,
 	}
 
 	if (bt_io_accept(chan, avctp_connect_browsing_cb, session, NULL,
-								&err))
+								&err)) {
+		avctp_set_state(session, AVCTP_STATE_BROWSING_CONNECTING);
 		return;
+	}
 
 	error("Browsing: %s", err->message);
 	g_error_free(err);
-- 
1.8.3.1


  parent reply	other threads:[~2013-07-29 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 14:04 [PATCH BlueZ 1/7] audio/AVRCP: Fix memory leaks Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 2/7] audio/AVRCP: Fix not connecting Browsing channel when supported Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 3/7] audio/AVRCP: Fix not setting browsing feature in CT record Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 4/7] audio/AVRCP: Connect browsing channel when accepting the connection Luiz Augusto von Dentz
2013-07-29 14:04 ` [PATCH BlueZ 5/7] audio/AVRCP: Connect browsing channel in case of GetCapabilities response Luiz Augusto von Dentz
2013-07-29 14:04 ` Luiz Augusto von Dentz [this message]
2013-07-29 14:04 ` [PATCH BlueZ 7/7] audio/AVCTP: Do not process browsing queue until connection completes Luiz Augusto von Dentz
2013-07-30  9:54 ` [PATCH BlueZ 1/7] audio/AVRCP: Fix memory leaks Johan Hedberg

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=1375106679-14645-6-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox