[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200311094223.GA15976@duo.ucw.cz>
Date: Wed, 11 Mar 2020 10:42:24 +0100
From: Pavel Machek <pavel@...x.de>
To: Michał Mirosław <mirq-linux@...e.qmqm.pl>
Cc: Pavel Machek <pavel@...x.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Sergey Organov <sorganov@...il.com>,
Felipe Balbi <balbi@...nel.org>,
Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 4.19 12/86] usb: gadget: serial: fix Tx stall after
buffer overflow
Hi!
> > > From: Sergey Organov <sorganov@...il.com>
> > >
> > > [ Upstream commit e4bfded56cf39b8d02733c1e6ef546b97961e18a ]
> > >
> > > Symptom: application opens /dev/ttyGS0 and starts sending (writing) to
> > > it while either USB cable is not connected, or nobody listens on the
> > > other side of the cable. If driver circular buffer overflows before
> > > connection is established, no data will be written to the USB layer
> > > until/unless /dev/ttyGS0 is closed and re-opened again by the
> > > application (the latter besides having no means of being notified about
> > > the event of establishing of the connection.)
> > >
> > > Fix: on open and/or connect, kick Tx to flush circular buffer data to
> > > USB layer.
> >
> > > diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> > > index d4d317db89df5..38afe96c5cd26 100644
> > > --- a/drivers/usb/gadget/function/u_serial.c
> > > +++ b/drivers/usb/gadget/function/u_serial.c
> > > @@ -567,8 +567,10 @@ static int gs_start_io(struct gs_port *port)
> > > port->n_read = 0;
> > > started = gs_start_rx(port);
> > >
> > > - /* unblock any pending writes into our circular buffer */
> > > if (started) {
> > > + gs_start_tx(port);
> > > + /* Unblock any pending writes into our circular buffer, in case
> > > + * we didn't in gs_start_tx() */
> > > tty_wakeup(port->port.tty);
> >
> > I'm confused. gs-start_tx() is done twice in a row. Its return
> > convention seem to be 0 in success case, and non-zero on failure. But
> > it is assigned to variable called "started", which does not sound like
> > "error" to me.
> >
> > Are you sure this is correct?
>
> The function before 'if (started)' is gs_start_rx() - it's RX not
> TX.
Aha, I missed that, sorry for the noise.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists