linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amit Nagal <helloin.amit@gmail.com>
To: jkosina@suse.cz
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Amit Nagal <helloin.amit@gmail.com>
Subject: [PATCH 1/1] HID: hidraw: open count should not increase if error
Date: Tue, 27 Sep 2011 13:41:58 -0400	[thread overview]
Message-ID: <1317145318-19656-1-git-send-email-helloin.amit@gmail.com> (raw)

In hidraw_open, if hid_hw_power returns with error,
hidraw device open count should not increase.

Signed-off-by: Amit Nagal <helloin.amit@gmail.com>
---
 drivers/hid/hidraw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index c841a8e..09bbcc9 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -271,8 +271,10 @@ static int hidraw_open(struct inode *inode, struct file *file)
 	dev = hidraw_table[minor];
 	if (!dev->open++) {
 		err = hid_hw_power(dev->hid, PM_HINT_FULLON);
-		if (err < 0)
+		if (err < 0) {
+			dev->open--;
 			goto out_unlock;
+		}
 
 		err = hid_hw_open(dev->hid);
 		if (err < 0) {
-- 
1.7.7-rc0


             reply	other threads:[~2011-09-27 12:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 17:41 Amit Nagal [this message]
2011-09-27 16:43 ` [PATCH 1/1] HID: hidraw: open count should not increase if error Jiri Kosina

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=1317145318-19656-1-git-send-email-helloin.amit@gmail.com \
    --to=helloin.amit@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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).