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>
This commit is contained in:
committed by
Dmitry Torokhov
parent
1ea3abf7fb
commit
064450140f
@@ -192,8 +192,11 @@ static int evdev_open_device(struct evdev *evdev)
|
|||||||
|
|
||||||
if (!evdev->exist)
|
if (!evdev->exist)
|
||||||
retval = -ENODEV;
|
retval = -ENODEV;
|
||||||
else if (!evdev->open++)
|
else if (!evdev->open++) {
|
||||||
retval = input_open_device(&evdev->handle);
|
retval = input_open_device(&evdev->handle);
|
||||||
|
if (retval)
|
||||||
|
evdev->open--;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&evdev->mutex);
|
mutex_unlock(&evdev->mutex);
|
||||||
return retval;
|
return retval;
|
||||||
|
@@ -205,8 +205,11 @@ static int joydev_open_device(struct joydev *joydev)
|
|||||||
|
|
||||||
if (!joydev->exist)
|
if (!joydev->exist)
|
||||||
retval = -ENODEV;
|
retval = -ENODEV;
|
||||||
else if (!joydev->open++)
|
else if (!joydev->open++) {
|
||||||
retval = input_open_device(&joydev->handle);
|
retval = input_open_device(&joydev->handle);
|
||||||
|
if (retval)
|
||||||
|
joydev->open--;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&joydev->mutex);
|
mutex_unlock(&joydev->mutex);
|
||||||
return retval;
|
return retval;
|
||||||
|
@@ -428,8 +428,11 @@ static int mousedev_open_device(struct mousedev *mousedev)
|
|||||||
mixdev_open_devices();
|
mixdev_open_devices();
|
||||||
else if (!mousedev->exist)
|
else if (!mousedev->exist)
|
||||||
retval = -ENODEV;
|
retval = -ENODEV;
|
||||||
else if (!mousedev->open++)
|
else if (!mousedev->open++) {
|
||||||
retval = input_open_device(&mousedev->handle);
|
retval = input_open_device(&mousedev->handle);
|
||||||
|
if (retval)
|
||||||
|
mousedev->open--;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&mousedev->mutex);
|
mutex_unlock(&mousedev->mutex);
|
||||||
return retval;
|
return retval;
|
||||||
|
@@ -185,8 +185,11 @@ static int tsdev_open_device(struct tsdev *tsdev)
|
|||||||
|
|
||||||
if (!tsdev->exist)
|
if (!tsdev->exist)
|
||||||
retval = -ENODEV;
|
retval = -ENODEV;
|
||||||
else if (!tsdev->open++)
|
else if (!tsdev->open++) {
|
||||||
retval = input_open_device(&tsdev->handle);
|
retval = input_open_device(&tsdev->handle);
|
||||||
|
if (retval)
|
||||||
|
tsdev->open--;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&tsdev->mutex);
|
mutex_unlock(&tsdev->mutex);
|
||||||
return retval;
|
return retval;
|
||||||
|
Reference in New Issue
Block a user