Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: USB tty devices can block in tcdrain when unplugged

The underlying problem is that the device methods don't all correctly
handle disconnected status and some keep reporting bytes pending which
causes tcdrain to stall.

When the cable is unplugged they are definitely gone, and as this is true
for all USB cables we can fix it in the core usb serial code.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
eff6937a 39aced68

+4
+4
drivers/usb/serial/usb-serial.c
··· 339 339 dbg("%s = port %d", __func__, port->number); 340 340 341 341 WARN_ON(!port->port.count); 342 + /* if the device was unplugged then any remaining characters 343 + fell out of the connector ;) */ 344 + if (port->serial->disconnected) 345 + return 0; 342 346 /* pass on to the driver specific version of this function */ 343 347 return port->serial->type->chars_in_buffer(tty); 344 348 }