浏览代码

tty: Fix USB kref leak

When we close we must clear the extra reference we got when we read
port->tty. Setting the port tty NULL will clear the kref held by the driver
but not the one we obtained ourselves while doing the lookup.

Signed-off-by: Alan Cox <alan@redhat.com>
Tested-by: Helge Hafting <helge.hafting@aitel.hist.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Alan Cox 16 年之前
父节点
当前提交
fce4877a67
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      drivers/usb/serial/usb-serial.c

+ 1 - 0
drivers/usb/serial/usb-serial.c

@@ -281,6 +281,7 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
 			if (tty->driver_data)
 				tty->driver_data = NULL;
 			tty_port_tty_set(&port->port, NULL);
+			tty_kref_put(tty);
 		}
 	}