Linux USB
 help / color / mirror / Atom feed
* [PATCH] USB: serial: f81232: drain work on failed open
@ 2026-11-16  5:10 Haowen Tu
  2026-11-16  5:17 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Haowen Tu @ 2026-11-16  5:10 UTC (permalink / raw)
  To: johan; +Cc: gregkh, linux-usb, linux-kernel, Haowen Tu

The interrupt URB is submitted before usb_serial_generic_open() starts
the bulk read URBs. A modem-status notification can therefore queue
interrupt_work before a bulk read submission fails. A bulk read that
completes before a later submission fails can also queue lsr_work.

The error path kills the interrupt URB but does not drain either work
item. The tty port is not initialized after a failed open, so the close
callback, which normally flushes this work, is not called. If the device
is then disconnected, the work can outlive the port private data it uses.

Flush both work items after killing the interrupt URB. The generic open
error path has already killed any submitted bulk read URBs, so neither
source can queue more work at this point.

Fixes: 87fe5adcd8de ("USB: f81232: implement read IIR/MSR with endpoint")
Signed-off-by: Haowen Tu <tuhaowen@uniontech.com>
---
 drivers/usb/serial/f81232.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 9a3ede35a3d9..b62e93e7612c 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -695,6 +695,7 @@ static int f81232_tiocmset(struct tty_struct *tty,
 
 static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
+	struct f81232_private *priv = usb_get_serial_port_data(port);
 	int result;
 
 	result = f81232_port_enable(port);
@@ -715,6 +716,8 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
 	result = usb_serial_generic_open(tty, port);
 	if (result) {
 		usb_kill_urb(port->interrupt_in_urb);
+		flush_work(&priv->interrupt_work);
+		flush_work(&priv->lsr_work);
 		return result;
 	}
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-16  5:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16  5:10 [PATCH] USB: serial: f81232: drain work on failed open Haowen Tu
2026-11-16  5:17 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox