USB: serial: io_edgeport: cap received transmit credits
Subsystems (2)
PATCH 1/1 USB: serial: io_edgeport: cap received transmit credits
The interrupt-status packet reports transmit credits returned by the device. edge_interrupt_callback() adds the 16-bit value to txCredits without checking maxTxCredits.
edge_write() uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.
Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.
--- drivers/usb/serial/io_edgeport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/serial/io_edgeport.c +4 -1
@@ -646,7 +646,10 @@ static void edge_interrupt_callback(struct urb *urb)if (edge_port && edge_port->open) {spin_lock_irqsave (&edge_port->ep_lock, flags); - edge_port->txCredits += txCredits; + edge_port->txCredits = + min_t(unsigned int, + edge_port->txCredits + txCredits, + edge_port->maxTxCredits);spin_unlock_irqrestore (&edge_port->ep_lock, flags); dev_dbg(dev, "%s - txcredits for port%d = %d\n",
base-commit: fad0fd120e29041b3e6cdf41bb12e3184fb524a2
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerQuoted 24 lines · Sunho Park
The interrupt-status packet reports transmit credits returned by the device.
edge_interrupt_callback()adds the 16-bit value to txCredits without checking maxTxCredits.
edge_write()uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Assisted-by Codex:GPT-5Signed-off-by Sunho Park <[email protected]>--- drivers/usb/serial/io_edgeport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/usb/serial/io_edgeport.c +0
-0
drivers/usb/serial/io_edgeport.c static void edge_interrupt_callback(struct urb *urb) · line 650
Quoted 6 lines
drivers/usb/serial/io_edgeport.c +2
-1@@ -646,7 +646,10 @@ static void edge_interrupt_callback(struct urb *urb)if (edge_port && edge_port->open) {spin_lock_irqsave (&edge_port->ep_lock, flags); - edge_port->txCredits += txCredits; + edge_port->txCredits = + min_t(unsigned int,
LLMs really love to use min_t() as they haven't been trained on modern kernel code.
Please don't use it, it shouldn't be needed here, right?
thanks,
greg k-h
You're right, I'll use it in v2.
Thanks,
Sunho
2026년 7월 14일 (화) 오후 6:38, Greg Kroah-Hartman <[email protected]>님이 작성:
Quoted 41 lines · Sunho Park
Quoted 24 lines
The interrupt-status packet reports transmit credits returned by the device.
edge_interrupt_callback()adds the 16-bit value to txCredits without checking maxTxCredits.
edge_write()uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Assisted-by Codex:GPT-5Signed-off-by Sunho Park <[email protected]>--- drivers/usb/serial/io_edgeport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/usb/serial/io_edgeport.c +0
-0drivers/usb/serial/io_edgeport.c static void edge_interrupt_callback(struct urb *urb) · line 650
Quoted 6 lines
drivers/usb/serial/io_edgeport.c +2
-1@@ -646,7 +646,10 @@ static void edge_interrupt_callback(struct urb *urb)if (edge_port && edge_port->open) {spin_lock_irqsave (&edge_port->ep_lock, flags); - edge_port->txCredits += txCredits; + edge_port->txCredits = + min_t(unsigned int,LLMs really love to use
min_t()as they haven't been trained on modern kernel code.Please don't use it, it shouldn't be needed here, right?
thanks,
greg k-h