]> Pileus Git - ~andy/linux/commitdiff
HID: hidraw: open count should not increase if error
authorAmit Nagal <helloin.amit@gmail.com>
Tue, 27 Sep 2011 17:41:58 +0000 (13:41 -0400)
committerJiri Kosina <jkosina@suse.cz>
Tue, 27 Sep 2011 16:42:22 +0000 (18:42 +0200)
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>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hidraw.c

index a8c2b7b6220a8316a159a263a426ee6360fd58a3..6d65d4e35120689ea8dd39827c12ed825060af42 100644 (file)
@@ -272,8 +272,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) {