linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/1] HID: hidraw: open count should not increase if error
  2011-09-27 17:41 [PATCH 1/1] HID: hidraw: open count should not increase if error Amit Nagal
@ 2011-09-27 16:43 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2011-09-27 16:43 UTC (permalink / raw)
  To: Amit Nagal; +Cc: linux-input, linux-kernel

On Tue, 27 Sep 2011, Amit Nagal wrote:

> 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) {

Good catch, thanks. Applied.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] HID: hidraw: open count should not increase if error
@ 2011-09-27 17:41 Amit Nagal
  2011-09-27 16:43 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Nagal @ 2011-09-27 17:41 UTC (permalink / raw)
  To: jkosina; +Cc: linux-input, linux-kernel, Amit Nagal

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-27 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 17:41 [PATCH 1/1] HID: hidraw: open count should not increase if error Amit Nagal
2011-09-27 16:43 ` Jiri Kosina

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).