On Fri, Jan 17, 2020 at 08:29:33AM +0300, Sergey Organov wrote: [...] > NOTE: current version of the driver leaks data from one connection to > another through its internal circular buffer. It might be a good idea > to clear the buffer on open/close/connect/disconnect, in which case > the problem this patch solves would have been fixed in a different > manner. However, not only that's a more dramatic change, but to do it > right TTY-layer buffers are to be considered as well. This is normal for serial devices, as they don't have any means to signal connection and will usually transmit anyway when not connected. In case of a console on the USB gadget-emulated serial port, it might actually be convenient that the data is kept until connection. > --- a/drivers/usb/gadget/function/u_serial.c > +++ b/drivers/usb/gadget/function/u_serial.c > @@ -563,6 +563,8 @@ static int gs_start_io(struct gs_port *port) > > /* unblock any pending writes into our circular buffer */ > if (started) { > + pr_debug("gs_start_tx: ttyGS%d\n", port->port_num); > + gs_start_tx(port); > tty_wakeup(port->port.tty); The tty_wakeup() will be called from gs_start_tx(), so should be removed from here. The pr_debug() in other callers of gs_start_tx() say: "caller: start ttyGS%d". Best Regards, Michał Mirosław