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 v2 BlueZ] android/hid: Fix not cleanup properly after disconnect
Date: Wed, 30 Oct 2013 16:24:54 +0200	[thread overview]
Message-ID: <1383143094-21262-1-git-send-email-luiz.dentz@gmail.com> (raw)

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

If the device is disconnected it should be removed from the list of
connected devices and free its data.
---
v2: Keep call to g_io_channel_shutdown

 android/hid.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/android/hid.c b/android/hid.c
index d6ca4b9..49e9c52 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -149,16 +149,11 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond,
 	if ((cond & (G_IO_HUP | G_IO_ERR)) && hdev->intr_watch)
 		g_io_channel_shutdown(chan, TRUE, NULL);
 
-	hdev->ctrl_watch = 0;
-
-	if (hdev->ctrl_io) {
-		g_io_channel_unref(hdev->ctrl_io);
-		hdev->ctrl_io = NULL;
-	}
-
 	if (hdev->intr_io && !(cond & G_IO_NVAL))
 		g_io_channel_shutdown(hdev->intr_io, TRUE, NULL);
 
+	hid_device_free(hdev);
+
 	return FALSE;
 }
 
@@ -230,8 +225,7 @@ static void control_connect_cb(GIOChannel *chan, GError *conn_err,
 	return;
 
 failed:
-	g_io_channel_unref(hdev->ctrl_io);
-	hdev->ctrl_io = NULL;
+	hid_device_free(hdev);
 }
 
 static uint8_t bt_hid_connect(struct hal_cmd_hid_connect *cmd, uint16_t len)
-- 
1.8.3.1


             reply	other threads:[~2013-10-30 14:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30 14:24 Luiz Augusto von Dentz [this message]
2013-10-30 14:42 ` [PATCH v2 BlueZ] android/hid: Fix not cleanup properly after disconnect 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=1383143094-21262-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