This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 5b71685e1ef usbdev/cdcacm: return write request to txfree when
EP_SUBMIT fails
5b71685e1ef is described below
commit 5b71685e1ef11596ad056ed666ceea77aa13cfd7
Author: Swatantra Yadav <[email protected]>
AuthorDate: Fri Nov 27 17:52:52 2026 +0530
usbdev/cdcacm: return write request to txfree when EP_SUBMIT fails
When EP_SUBMIT() on bulk IN or interrupt IN fails (e.g. endpoint is shut
down due to cable disconnection, reconfiguration, or stalled endpoint
returning -ESHUTDOWN or -EBUSY), the write request container is removed
from priv->txfree and priv->nwrq is decremented, but never returned upon
submission failure.
Because EP_SUBMIT() did not accept the request, the USB device controller
will never invoke cdcacm_wrcomplete() for it. Consequently, each failed
submit permanently leaks one write container and leaves priv->nwrq
permanently decremented. After CONFIG_CDCACM_NWRREQS failures, priv->nwrq
reaches 0, permanently stalling the transmit path on /dev/ttyACMx.
This patch returns wrcontainer to priv->txfree via sq_addlast() and
restores priv->nwrq++ across all three submission error paths:
- cdcuart_sendbuf (polling write path)
- cdcacm_serialstate (serial state notification path)
- cdcuart_dmasend (DMA/TXBUF write path)
Fixes #22304
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Swatantra Yadav <[email protected]>
---
drivers/usbdev/cdcacm.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/usbdev/cdcacm.c b/drivers/usbdev/cdcacm.c
index 92f457fa3e9..86e69ae4954 100644
--- a/drivers/usbdev/cdcacm.c
+++ b/drivers/usbdev/cdcacm.c
@@ -410,6 +410,10 @@ static ssize_t cdcuart_sendbuf(FAR struct uart_dev_s *dev,
{
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL),
(uint16_t)-ret);
+ flags = spin_lock_irqsave(&priv->lock);
+ sq_addlast((FAR sq_entry_t *)wrcontainer, &priv->txfree);
+ priv->nwrq++;
+ spin_unlock_irqrestore(&priv->lock, flags);
return ret;
}
@@ -854,6 +858,10 @@ static int cdcacm_serialstate(FAR struct cdcacm_dev_s
*priv)
if (ret < 0)
{
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16_t)-ret);
+ flags = spin_lock_irqsave(&priv->lock);
+ sq_addlast((FAR sq_entry_t *)wrcontainer, &priv->txfree);
+ priv->nwrq++;
+ spin_unlock_irqrestore(&priv->lock, flags);
}
errout_with_flags:
@@ -3123,6 +3131,8 @@ static void cdcuart_dmasend(FAR struct uart_dev_s *dev)
{
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL),
(uint16_t)-ret);
+ sq_addlast((FAR sq_entry_t *)wrcontainer, &priv->txfree);
+ priv->nwrq++;
}
}
#endif