Repository navigation
Description
Description / Steps to reproduce the issue
When EP_SUBMIT() on the bulk IN endpoint fails, cdcacm neither puts the write container back on priv->txfree nor restores priv->nwrq, so every failed submit leaks one write request. After CONFIG_CDCACM_NWRREQS failures nwrq stays 0 and the TX path is dead: data written to /dev/ttyACMx stays in the xmit buffer and never reaches the host.
In cdcuart_dmasend() (the default path, TXBUF enabled):
wrcontainer = (FAR struct cdcacm_wrreq_s *)sq_remfirst(&priv->txfree);
req = wrcontainer->req;
priv->nwrq--;
...
ret = EP_SUBMIT(ep, req);
if (ret < 0)
{
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL),
(uint16_t)-ret);
} /* wrcontainer is neither queued nor returned */By inspection (not reproduced), the polling write path (the one that sets priv->ispolling) has the same pattern: The CONFIG_CDCACM_DISABLE_TXBUF path in cdcacm_sndpacket() keeps the container in priv->wrcontainer, so it does not seem affected.
A failing EP_SUBMIT() is a legitimate result: several in-tree device controller drivers return -ESHUTDOWN from ep_submit (e.g. no class driver bound) or -EBUSY (endpoint stalled). The write completion path, cdcacm_wrcomplete(), already handles -ESHUTDOWN correctly because it always returns the container first, so the submit-failure path is just inconsistent with it.
Steps to reproduce
Found while bringing up a USB device controller driver whose ep_submit returns -ESHUTDOWN while the endpoint is not configured. Linux host, CDC/ACM, CONFIG_CDCACM_NWRREQS=4:
- On the device, write continuously to
/dev/ttyACM0, e.g.dd if=/dev/zero of=/dev/ttyACM0 bs=64 count=32768. - While it runs, on the host send SET_CONFIGURATION(0) then (1):
echo 0 > /sys/bus/usb/devices/<dev>/bConfigurationValue; sleep 1; echo 1 > /sys/bus/usb/devices/<dev>/bConfigurationValue - Each cycle logs one
SUBMITFAIL(value0x6c=ESHUTDOWN) from a write that lands between the two requests. - After the 4th cycle,
echo X > /dev/ttyACM0on the device no longer reaches the host.
State read with a debugger at that point: the endpoint's request queue is empty, the controller and its DMA are idle, cdcacm nwrq == 0, and the xmit buffer still holds the 8 unsent bytes.
Suggested fix
On EP_SUBMIT() failure, return the container and restore the count, as cdcacm_wrcomplete() does:
if (ret < 0)
{
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL),
(uint16_t)-ret);
flags = enter_critical_section();
sq_addlast((FAR sq_entry_t *)wrcontainer, &priv->txfree);
priv->nwrq++;
leave_critical_section(flags);
}and the same in the polling path before return ret.
Seen on 12.12. Not run on master, but this code is unchanged there as of 44c01c2 (2026-11-19).
On which OS does this issue occur?
[OS: Linux]
What is the version of your OS?
Ubuntu 26.04.1 LTS
NuttX Version
12.12 (code unchanged on master 44c01c2)
Issue Architecture
[Arch: all]
Issue Area
[Area: Drivers]
Host information
No response
Verification
- I have verified before submitting the report.
Activity
[-][BUG] <usbdev/cdcacm: write request leaked when EP_SUBMIT fails>[/-][+][BUG] usbdev/cdcacm: write request leaked when EP_SUBMIT fails[/+]kg290 commentedon Nov 25, 2026
ill try to reproduce this and fix it, thanks!
usbdev/cdcacm: return write request to txfree when EP_SUBMIT fails