From: Alan Cox Date: Sat, 19 Sep 2009 20:13:23 +0000 (-0700) Subject: tty: USB hangup is racy X-Git-Tag: v2.6.31.2~48 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=08f30ff9811e59c08d1cee043ce55b2e862efe58;p=karo-tx-linux.git tty: USB hangup is racy commit d2b391822a11302add9e46476f3da4e18e6de84c upstream. The USB layer uses tty_hangup to deal with unplugs of the physical hardware (analogous to loss of carrier) and then frees the resources. However the tty_hangup is asynchronous. As the hangup can sleep we can use tty_vhangup which is the non async version to avoid freeing resources too early. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 99188c92068b..21dd72a5a715 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -1161,10 +1161,7 @@ void usb_serial_disconnect(struct usb_interface *interface) if (port) { struct tty_struct *tty = tty_port_tty_get(&port->port); if (tty) { - /* The hangup will occur asynchronously but - the object refcounts will sort out all the - cleanup */ - tty_hangup(tty); + tty_vhangup(tty); tty_kref_put(tty); } kill_traffic(port);