summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2007-10-12 14:18:40 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-08 12:01:42 -0800
commit8fdb939daf356463911a58daf8b9146e6ee7cf81 (patch)
treed3fa87585fce38f5eb8cd9c91e7162ce57a9c9d5
parent71915ded634a0a317b6f579d3c39112657e9a34d (diff)
downloadlinux-stable-8fdb939daf356463911a58daf8b9146e6ee7cf81.tar.gz
linux-stable-8fdb939daf356463911a58daf8b9146e6ee7cf81.tar.bz2
linux-stable-8fdb939daf356463911a58daf8b9146e6ee7cf81.zip
Input: fix open count handling in input interfaces
patch 064450140f1eab959bd0eca0245f449993216074 in mainline. If input_open_device() fails we should not leave interfaces marked as opened. Signed-off-by: Oliver Neukum <oneukum@suse.de> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/input/evdev.c5
-rw-r--r--drivers/input/joydev.c5
-rw-r--r--drivers/input/mousedev.c5
-rw-r--r--drivers/input/tsdev.c5
4 files changed, 16 insertions, 4 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 4eb2805b7173..27026f7d3c03 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 a4272d63c4d6..f306c97f556d 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 715def79390c..cc36edbb912f 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 c189f1dd569f..120233493758 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;