Skip to content

Commit

Permalink
tty: Fix USB kref leak
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alan Cox authored and torvalds committed Jul 11, 2009
1 parent 4cd1de0 commit 24a15a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/usb/serial/ftdi_sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
7 changes: 4 additions & 3 deletions drivers/usb/serial/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/serial/pl2303.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion include/linux/usb/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 24a15a6

Please sign in to comment.