[PATCH] [199/275] USB: serial/kobil_sct, fix potential tty NULL dereference

From: Andi Kleen
Date: Wed Mar 30 2011 - 17:28:47 EST


2.6.35-longterm review patch. If anyone has any objections, please let me know.

------------------
From: Jiri Slaby <jslaby@xxxxxxx>

commit 6960f40a954619857e7095a6179eef896f297077 upstream.

Make sure that we check the return value of tty_port_tty_get.
Sometimes it may return NULL and we later dereference that.

The only place here is in kobil_read_int_callback, so fix it.

Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: Alan Cox <alan@xxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/usb/serial/kobil_sct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.35.y/drivers/usb/serial/kobil_sct.c
===================================================================
--- linux-2.6.35.y.orig/drivers/usb/serial/kobil_sct.c 2011-03-29 22:50:40.699217027 -0700
+++ linux-2.6.35.y/drivers/usb/serial/kobil_sct.c 2011-03-29 23:03:02.423238165 -0700
@@ -372,7 +372,7 @@
}

tty = tty_port_tty_get(&port->port);
- if (urb->actual_length) {
+ if (tty && urb->actual_length) {

/* BEGIN DEBUG */
/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/