error handling in tty_open

Oliver Neukum <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Novell
Message-ID <[email protected]>
Hi,

it turns out that tty_open() calls close() even if open() has failed.
As this is undesireable for usb serial drivers, here's a patch
to deal with it.

John, does it fix the issue you reported?

	Regards
		Oliver
-- 

--- a/include/linux/usb/serial.h	2007-03-26 09:23:20.000000000 +0200
+++ b/include/linux/usb/serial.h	2007-03-26 09:27:12.000000000 +0200
@@ -92,6 +92,7 @@
 	int			open_count;
 	char			throttled;
 	char			throttle_req;
+	int			cleaning_up;
 	struct device		dev;
 };
 #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
--- a/drivers/usb/serial/usb-serial.c	2007-03-26 09:18:08.000000000 +0200
+++ b/drivers/usb/serial/usb-serial.c	2007-03-26 09:28:14.000000000 +0200
@@ -235,6 +235,7 @@
 	return 0;
 
 bailout_module_put:
+	++port->cleaning_up;
 	module_put(serial->type->driver.owner);
 bailout_mutex_unlock:
 	port->open_count = 0;
@@ -257,6 +258,12 @@
 
 	mutex_lock(&port->mutex);
 
+	if (port->cleaning_up) {
+		--port->cleaning_up;
+		mutex_unlock(&port->mutex);
+		return;
+	}
+
 	if (port->open_count == 0) {
 		mutex_unlock(&port->mutex);
 		return;


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.