[patch 53/73] Input: fix open count handling in input interfaces

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>, <stable@...>
Cc: Justin Forbes <jmforbes@...>, Zwane Mwaikambo <zwane@...>, Theodore Ts'o <tytso@...>, Randy Dunlap <rdunlap@...>, Dave Jones <davej@...>, Chuck Wolber <chuckw@...>, Chris Wedgwood <reviews@...>, Michael Krufky <mkrufky@...>, Chuck Ebbert <cebbert@...>, Domenico Andreoli <cavokz@...>, <torvalds@...>, <akpm@...>, <alan@...>, Oliver Neukum <oneukum@...>, Al Viro <viro@...>, Dmitry Torokhov <dtor@...>
Date: Wednesday, February 6, 2008 - 7:53 pm

2.6.23-stable review patch.  If anyone has any objections, please let us know.
------------------
From: Oliver Neukum <oliver@neukum.org>

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>

---
 drivers/input/evdev.c    |    5 ++++-
 drivers/input/joydev.c   |    5 ++++-
 drivers/input/mousedev.c |    5 ++++-
 drivers/input/tsdev.c    |    5 ++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -192,8 +192,11 @@ static int evdev_open_device(struct evde
 
 	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;
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -205,8 +205,11 @@ static int joydev_open_device(struct joy
 
 	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;
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -428,8 +428,11 @@ static int mousedev_open_device(struct m
 		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;
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -185,8 +185,11 @@ static int tsdev_open_device(struct tsde
 
 	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;

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/73] 2.6.23-stable review, Greg KH, (Wed Feb 6, 7:50 pm)
[patch 73/73] PCI: Fix fakephp deadlock, Greg KH, (Wed Feb 6, 7:54 pm)
[patch 72/73] ACPI: sync blacklist w/ latest, Greg KH, (Wed Feb 6, 7:54 pm)
[patch 71/73] atl1: fix frame length bug, Greg KH, (Wed Feb 6, 7:54 pm)
[patch 70/73] forcedeth: mac address mcp77/79, Greg KH, (Wed Feb 6, 7:54 pm)
[patch 66/73] fix oops on rmmod capidrv, Greg KH, (Wed Feb 6, 7:54 pm)
[patch 64/73] spi: omap2_mcspi PIO RX fix, Greg KH, (Wed Feb 6, 7:54 pm)
[patch 55/73] m68k: Export cachectl.h, Greg KH, (Wed Feb 6, 7:53 pm)
[patch 53/73] Input: fix open count handling in input interf..., Greg KH, (Wed Feb 6, 7:53 pm)
[patch 47/73] cxgb: fix stats, Greg KH, (Wed Feb 6, 7:53 pm)
[patch 46/73] cxgb: fix T2 GSO, Greg KH, (Wed Feb 6, 7:53 pm)
[patch 45/73] chelsio: Fix skb-&gt;dev setting, Greg KH, (Wed Feb 6, 7:53 pm)
[patch 28/73] CASSINI: Fix endianness bug., Greg KH, (Wed Feb 6, 7:52 pm)
[patch 16/73] X25: Add missing x25_neigh_put, Greg KH, (Wed Feb 6, 7:51 pm)
[patch 14/73] sky2: RX lockup fix, Greg KH, (Wed Feb 6, 7:51 pm)
[patch 04/73] dm crypt: use bio_add_page, Greg KH, (Wed Feb 6, 7:50 pm)
[patch 03/73] dm crypt: fix write endio, Greg KH, (Wed Feb 6, 7:50 pm)