diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index bfee4f9a77151053e366f2e8ef80dd497441c4cb..d404aa8680ea1aa83c660a8a5f5ef98059fcb66c 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -192,8 +192,11 @@ static int evdev_open_device(struct evdev *evdev) if (!evdev->exist) retval = -ENODEV; - else if (!evdev->open++) + else if (!evdev->open++) { retval = input_open_device(&evdev->handle); + if (retval) + evdev->open--; + } mutex_unlock(&evdev->mutex); return retval; diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index a4272d63c4d6c18b134f585003c5db97c9e58d1d..f306c97f556dc9dd3f68ffc78523885799baa4ce 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c @@ -205,8 +205,11 @@ static int joydev_open_device(struct joydev *joydev) if (!joydev->exist) retval = -ENODEV; - else if (!joydev->open++) + else if (!joydev->open++) { retval = input_open_device(&joydev->handle); + if (retval) + joydev->open--; + } mutex_unlock(&joydev->mutex); return retval; diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 715def79390c68d89017663dedfed82c0bb91d42..cc36edbb912f1b137e24c70941cdd21becff3cfb 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c @@ -428,8 +428,11 @@ static int mousedev_open_device(struct mousedev *mousedev) mixdev_open_devices(); else if (!mousedev->exist) retval = -ENODEV; - else if (!mousedev->open++) + else if (!mousedev->open++) { retval = input_open_device(&mousedev->handle); + if (retval) + mousedev->open--; + } mutex_unlock(&mousedev->mutex); return retval; diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c index c189f1dd569f42f3451eae6e8bda519f47fc7fed..120233493758456294e3a162a8f6c30f2f35e5db 100644 --- a/drivers/input/tsdev.c +++ b/drivers/input/tsdev.c @@ -185,8 +185,11 @@ static int tsdev_open_device(struct tsdev *tsdev) if (!tsdev->exist) retval = -ENODEV; - else if (!tsdev->open++) + else if (!tsdev->open++) { retval = input_open_device(&tsdev->handle); + if (retval) + tsdev->open--; + } mutex_unlock(&tsdev->mutex); return retval;