OSDN Git Service

usb: gadget: serial: fix Tx stall after buffer overflow
authorSergey Organov <sorganov@gmail.com>
Wed, 29 Jan 2020 11:21:46 +0000 (14:21 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Mar 2020 13:14:49 +0000 (14:14 +0100)
commitdcfc1ec7bb6dccedcc5b017284ff0b21f895a35f
tree3122b7d78867375858e0a888660be66f17c8f2db
parentec23941e27f94b6e0f641181f0c42baafc3cf2ac
usb: gadget: serial: fix Tx stall after buffer overflow

[ 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.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/function/u_serial.c