瀏覽代碼

HID: hidraw: open count should not increase if error

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>
Amit Nagal 14 年之前
父節點
當前提交
f554ff8033
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      drivers/hid/hidraw.c

+ 3 - 1
drivers/hid/hidraw.c

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