[PATCH v2 02/12] USB: serial: io_edgeport: fix potential close() use-after-free

From: Johan Hovold

Date: Fri Oct 23 2026 - 08:19:45 EST


Add the missing open check on write() and locking when updating the port
status during close() to prevent a racing interrupt completion handler
from trying to submit more data for the port while its write URB and
FIFO are being deallocated.

This issue was flagged by Sashiko when reviewing a related fix.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Link: https://sashiko.dev/#/patchset/20260714101316.823942-1-shpark061104%40gmail.com?part=1
Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
drivers/usb/serial/io_edgeport.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index cdf41e86ba44..a5011fa91ee7 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1085,7 +1085,9 @@ static void edge_close(struct usb_serial_port *port)

/* port->close = true; */
edge_port->closePending = false;
+ spin_lock_irq(&edge_port->ep_lock);
edge_port->open = false;
+ spin_unlock_irq(&edge_port->ep_lock);
edge_port->openPending = false;

usb_kill_urb(edge_port->write_urb);
@@ -1127,6 +1129,12 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,

spin_lock_irqsave(&edge_port->ep_lock, flags);

+ /* avoid accessing freed fifo if tty_wakeup() races with close() */
+ if (!edge_port->open) {
+ spin_unlock_irqrestore(&edge_port->ep_lock, flags);
+ return 0;
+ }
+
/* calculate number of bytes to put in fifo */
copySize = min_t(unsigned int, count,
(edge_port->txCredits - fifo->count));
--
2.55.0