tty: Fix USB kref leak
authorAlan Cox <alan@linux.intel.com>
Thu, 9 Jul 2009 12:36:22 +0000 (13:36 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 11 Jul 2009 02:17:22 +0000 (19:17 -0700)
The sysrq code acquired a kref leak. Fix it by passing the tty separately
from the caller (thus effectively using the callers kref which all the
callers hold anyway)

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/generic.c
drivers/usb/serial/pl2303.c
include/linux/usb/serial.h

index 3dc3768ca71ca0afb4a2a8f19541b3b345787b72..5f08702f672f6bd84921a474b8c654c1c9fb87d9 100644 (file)
@@ -2121,7 +2121,7 @@ static void ftdi_process_read(struct work_struct *work)
                                /* Note that the error flag is duplicated for
                                   every character received since we don't know
                                   which character it applied to */
-                               if (!usb_serial_handle_sysrq_char(port,
+                               if (!usb_serial_handle_sysrq_char(tty, port,
                                                data[packet_offset + i]))
                                        tty_insert_flip_char(tty,
                                                data[packet_offset + i],
index 3d8dc5671beaca5eeb4500bdd3adcb9c5a965a5e..ce57f6a32bdfb4cc7a5e30f78c1e8eca21a9364a 100644 (file)
@@ -432,7 +432,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
        else {
                /* Push data to tty */
                for (i = 0; i < urb->actual_length; i++, ch++) {
-                       if (!usb_serial_handle_sysrq_char(port, *ch))
+                       if (!usb_serial_handle_sysrq_char(tty, port, *ch))
                                tty_insert_flip_char(tty, *ch, TTY_NORMAL);
                }
        }
@@ -534,11 +534,12 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
        }
 }
 
-int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
+int usb_serial_handle_sysrq_char(struct tty_struct *tty,
+                       struct usb_serial_port *port, unsigned int ch)
 {
        if (port->sysrq && port->console) {
                if (ch && time_before(jiffies, port->sysrq)) {
-                       handle_sysrq(ch, tty_port_tty_get(&port->port));
+                       handle_sysrq(ch, tty);
                        port->sysrq = 0;
                        return 1;
                }
index ec6c132a25b56f0a63ffa3b0b3a702594d1097b3..8835802067f7ac26eb5d00b46c2e260881dd9c48 100644 (file)
@@ -1038,7 +1038,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
                if (line_status & UART_OVERRUN_ERROR)
                        tty_insert_flip_char(tty, 0, TTY_OVERRUN);
                for (i = 0; i < urb->actual_length; ++i)
-                       if (!usb_serial_handle_sysrq_char(port, data[i]))
+                       if (!usb_serial_handle_sysrq_char(tty, port, data[i]))
                                tty_insert_flip_char(tty, data[i], tty_flag);
                tty_flip_buffer_push(tty);
        }
index 44801d26a37a7888d7ebd88dbb5cf0e4a1836de0..0ec50ba62139e5bde97db61a10b8585c2882c916 100644 (file)
@@ -317,7 +317,8 @@ extern int usb_serial_generic_register(int debug);
 extern void usb_serial_generic_deregister(void);
 extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
                                                 gfp_t mem_flags);
-extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port,
+extern int usb_serial_handle_sysrq_char(struct tty_struct *tty,
+                                       struct usb_serial_port *port,
                                        unsigned int ch);
 extern int usb_serial_handle_break(struct usb_serial_port *port);