HID: hidraw: open count should not increase if error
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.
Signed-off-by Amit Nagal <[email protected]>
--- drivers/hid/hidraw.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/hid/hidraw.c +3 -1
@@ -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
Quoted 14 lines · Amit Nagal
In
hidraw_open, ifhid_hw_powerreturns with error, hidraw device open count should not increase.Signed-off-by Amit Nagal <[email protected]>--- drivers/hid/hidraw.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)drivers/hid/hidraw.c +0
-0@@ -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
-1if (!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