[PATCH] USB: fix oops in serial_write

Linux Kernel Mailing List <[email protected]> Tue, 22 Mar 2005 17:30:33 +0000
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1468, 2005/03/22 14:30:33-03:00, [email protected]

	[PATCH] USB: fix oops in serial_write
	
	When I split the __serial_write off serial_write, the former took the NULL
	check away with it. However, the new serial_write still has an reference
	remaining in down(&port->sem). Joachim Nilsson corrected me.



 usbserial.c |    3 +++
 1 files changed, 3 insertions(+)


diff -Nru a/drivers/usb/serial/usbserial.c b/drivers/usb/serial/usbserial.c
--- a/drivers/usb/serial/usbserial.c	2005-03-24 09:05:37 -08:00
+++ b/drivers/usb/serial/usbserial.c	2005-03-24 09:05:37 -08:00
@@ -715,6 +715,9 @@
 	struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
 	int rc;
 
+	if (!port)
+		return -ENODEV;
+
 	if (!in_interrupt()) {
 		/*
 		 * Run post_list to reduce a possiblity of reordered writes.