[PATCH 04/11] USB: serial: io_edgeport: fix potential NULL-deref at open

From: Johan Hovold

Date: Wed Oct 21 2026 - 10:22:14 EST


Do not mark the port as open until after the write FIFO has been
allocated and initialised to prevent a racing interrupt completion from
attempting to send stale data and dereferencing the FIFO buffer pointer.

Note that the open flag defaults to false and is cleared on close() so
there is no need to reinitialise it on every open().

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
drivers/usb/serial/io_edgeport.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index a2410c063ffe..38f58ca115eb 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -889,9 +889,8 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)

/* send a open port command */
edge_port->openPending = true;
- edge_port->open = false;
- response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0);

+ response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0);
if (response < 0) {
dev_err(dev, "%s - error sending open port command\n", __func__);
edge_port->openPending = false;
@@ -901,8 +900,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
/* now wait for the port to be completely opened */
wait_event_timeout(edge_port->wait_open, !edge_port->openPending,
OPEN_TIMEOUT);
-
- if (!edge_port->open) {
+ if (edge_port->openPending) {
/* open timed out */
dev_dbg(dev, "%s - open timeout\n", __func__);
edge_port->openPending = false;
@@ -930,6 +928,10 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
return -ENOMEM;
}

+ spin_lock_irq(&edge_port->ep_lock);
+ edge_port->open = true;
+ spin_unlock_irq(&edge_port->ep_lock);
+
dev_dbg(dev, "%s - Initialize TX fifo to %d bytes\n",
__func__, edge_port->maxTxCredits);

@@ -1092,7 +1094,6 @@ static void edge_close(struct usb_serial_port *port)
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);

@@ -1824,7 +1825,6 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,

/* we have completed the open */
edge_port->openPending = false;
- edge_port->open = true;
wake_up(&edge_port->wait_open);
return;
}
--
2.55.0