Skip to contentSkip to conversation

HID: hidraw: open count should not increase if error

PATCH In review Amit Nagal 2 participants 2 messages Sep 27, 2011 HID

lore
Share & tools
lore

Amit Nagal

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/hid/hidraw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/hid/hidraw.c +3 -1
index c841a8e..09bbcc9 100644
@@ -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) {
Signature · 1 line
1.7.7-rc0
#1 lore raw
Quoted 14 lines · Amit Nagal

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

---
 drivers/hid/hidraw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/hid/hidraw.c +0 -0
index c841a8e..09bbcc9 100644
@@ -271,8 +271,10 @@ static int hidraw_open(struct inode *inode, struct file *file)
 	dev = hidraw_table[minor];

drivers/hid/hidraw.c static int hidraw_open(struct inode *inode, struct file *file) · line 280

Quoted 10 lines
drivers/hid/hidraw.c +3 -1
 	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.

Signature · 2 lines
Jiri Kosina
SUSE Labs