From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/3] audio/AVDTP: Fix crash after disconnecting
Date: Mon, 14 Oct 2013 13:14:45 +0300 [thread overview]
Message-ID: <1381745687-5677-1-git-send-email-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the session is disconnected while process_discover is pending the
source id is not removed causing the following crash:
at 0x414C08: finalize_discovery (avdtp.c:1050)
by 0x414C5A: process_discover (avdtp.c:3346)
by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x40A3B6: main (main.c:595)
Address 0x5e25de8 is 1,144 bytes inside a block of size 1,176 free'd
at 0x4A074C4: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x3D4604D9AE: g_free (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x4152F2: connection_lost (avdtp.c:1206)
by 0x4162C4: cancel_request (avdtp.c:2662)
by 0x4164BD: request_timeout (avdtp.c:2672)
by 0x3D46048962: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
by 0x40A3B6: main (main.c:595)
---
profiles/audio/avdtp.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 622dff8..57e644c 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -412,6 +412,7 @@ struct avdtp {
char *buf;
+ guint discov_id;
avdtp_discover_cb_t discov_cb;
void *user_data;
@@ -1048,6 +1049,11 @@ static void finalize_discovery(struct avdtp *session, int err)
if (!session->discov_cb)
return;
+ if (session->discov_id > 0) {
+ g_source_remove(session->discov_id);
+ session->discov_id = 0;
+ }
+
session->discov_cb(session, session->seps,
err ? &avdtp_err : NULL,
session->user_data);
@@ -3322,6 +3328,8 @@ static gboolean process_discover(gpointer data)
{
struct avdtp *session = data;
+ session->discov_id = 0;
+
finalize_discovery(session, 0);
return FALSE;
@@ -3338,7 +3346,7 @@ int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
if (session->seps) {
session->discov_cb = cb;
session->user_data = user_data;
- g_idle_add(process_discover, session);
+ session->discov_id = g_idle_add(process_discover, session);
return 0;
}
--
1.8.3.1
next reply other threads:[~2013-10-14 10:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-14 10:14 Luiz Augusto von Dentz [this message]
2013-10-14 10:14 ` [PATCH BlueZ 2/3] audio/AVDTP: Add struct for discover specific data Luiz Augusto von Dentz
2013-10-14 10:14 ` [PATCH BlueZ 3/3] obexd/session: Fix crash when transport is disconnected Luiz Augusto von Dentz
2013-10-15 6:57 ` [PATCH BlueZ 1/3] audio/AVDTP: Fix crash after disconnecting 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=1381745687-5677-1-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