Commit 064450140f1eab959bd0eca0245f449993216074
Committed by
Dmitry Torokhov
1 parent
1ea3abf7fb
Input: fix open count handling in input interfaces
If input_open_device() fails we should not leave interfaces marked as opened. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Showing 4 changed files with 16 additions and 4 deletions Side-by-side Diff
drivers/input/evdev.c
... | ... | @@ -192,8 +192,11 @@ |
192 | 192 | |
193 | 193 | if (!evdev->exist) |
194 | 194 | retval = -ENODEV; |
195 | - else if (!evdev->open++) | |
195 | + else if (!evdev->open++) { | |
196 | 196 | retval = input_open_device(&evdev->handle); |
197 | + if (retval) | |
198 | + evdev->open--; | |
199 | + } | |
197 | 200 | |
198 | 201 | mutex_unlock(&evdev->mutex); |
199 | 202 | return retval; |
drivers/input/joydev.c
... | ... | @@ -205,8 +205,11 @@ |
205 | 205 | |
206 | 206 | if (!joydev->exist) |
207 | 207 | retval = -ENODEV; |
208 | - else if (!joydev->open++) | |
208 | + else if (!joydev->open++) { | |
209 | 209 | retval = input_open_device(&joydev->handle); |
210 | + if (retval) | |
211 | + joydev->open--; | |
212 | + } | |
210 | 213 | |
211 | 214 | mutex_unlock(&joydev->mutex); |
212 | 215 | return retval; |
drivers/input/mousedev.c
... | ... | @@ -428,8 +428,11 @@ |
428 | 428 | mixdev_open_devices(); |
429 | 429 | else if (!mousedev->exist) |
430 | 430 | retval = -ENODEV; |
431 | - else if (!mousedev->open++) | |
431 | + else if (!mousedev->open++) { | |
432 | 432 | retval = input_open_device(&mousedev->handle); |
433 | + if (retval) | |
434 | + mousedev->open--; | |
435 | + } | |
433 | 436 | |
434 | 437 | mutex_unlock(&mousedev->mutex); |
435 | 438 | return retval; |
drivers/input/tsdev.c
... | ... | @@ -185,8 +185,11 @@ |
185 | 185 | |
186 | 186 | if (!tsdev->exist) |
187 | 187 | retval = -ENODEV; |
188 | - else if (!tsdev->open++) | |
188 | + else if (!tsdev->open++) { | |
189 | 189 | retval = input_open_device(&tsdev->handle); |
190 | + if (retval) | |
191 | + tsdev->open--; | |
192 | + } | |
190 | 193 | |
191 | 194 | mutex_unlock(&tsdev->mutex); |
192 | 195 | return retval; |