From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Subject: [PATCH] android/hidhost: Fix error handling issue incase of G_IO_HUP
Date: Tue, 12 Nov 2013 15:05:15 +0200 [thread overview]
Message-ID: <1384261515-28725-1-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
Incase of G_IO_HUP on GIOCondtion when hid device disconnected,
GIOCondition is combination of G_IO_IN and G_IO_HUP. Current code
tries to read as soon as it finds G_IO_IN in condition.
Apparently there is no data to read and loop continues.
---
android/hidhost.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 491eacd..cba80a6 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -282,26 +282,27 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond,
{
struct hid_device *dev = data;
+ if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL))
+ goto error;
+
if (cond & G_IO_IN)
return intr_io_watch_cb(chan, data);
+error:
+ bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTED);
+
/* Checking for ctrl_watch avoids a double g_io_channel_shutdown since
* it's likely that ctrl_watch_cb has been queued for dispatching in
* this mainloop iteration */
if ((cond & (G_IO_HUP | G_IO_ERR)) && dev->ctrl_watch)
g_io_channel_shutdown(chan, TRUE, NULL);
- dev->intr_watch = 0;
-
- if (dev->intr_io) {
- g_io_channel_unref(dev->intr_io);
- dev->intr_io = NULL;
- }
-
/* Close control channel */
if (dev->ctrl_io && !(cond & G_IO_NVAL))
g_io_channel_shutdown(dev->ctrl_io, TRUE, NULL);
+ hid_device_free(dev);
+
return FALSE;
}
@@ -442,12 +443,14 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
struct hid_device *dev = data;
- char address[18];
+
+ if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL))
+ goto error;
if (cond & G_IO_IN)
return ctrl_io_watch_cb(chan, data);
- ba2str(&dev->dst, address);
+error:
bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTED);
/* Checking for intr_watch avoids a double g_io_channel_shutdown since
--
1.8.3.2
next reply other threads:[~2013-11-12 13:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-12 13:05 Ravi kumar Veeramally [this message]
2013-11-12 13:28 ` [PATCH] android/hidhost: Fix error handling issue incase of G_IO_HUP 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=1384261515-28725-1-git-send-email-ravikumar.veeramally@linux.intel.com \
--to=ravikumar.veeramally@linux.intel.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;
as well as URLs for NNTP newsgroup(s).