Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 054f2346 authored by Jiri Slaby's avatar Jiri Slaby Committed by Live-CD User
Browse files

tty: USB: serial/mct_u232, fix tty refcnt

Stanse found a tty refcnt leak in read_int_callback. In fact
it's handled wrong altogether. tty_port_tty_get can return NULL
and it's not checked in that manner.

Fix that by checking the tty_port_tty_get retval and put tty kref
properly.

http://stanse.fi.muni.cz/



Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7e63d0c4
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -566,10 +566,13 @@ static void mct_u232_read_int_callback(struct urb *urb)
	 * Work-a-round: handle the 'usual' bulk-in pipe here
	 */
	if (urb->transfer_buffer_length > 2) {
		tty = tty_port_tty_get(&port->port);
		if (urb->actual_length) {
			tty_insert_flip_string(tty, data, urb->actual_length);
			tty = tty_port_tty_get(&port->port);
			if (tty) {
				tty_insert_flip_string(tty, data,
						urb->actual_length);
				tty_flip_buffer_push(tty);
			}
			tty_kref_put(tty);
		}
		goto exit;