Repository navigation
usbdev/cdcacm: return write request to txfree when EP_SUBMIT fails - #22495
Merged
GUIDINGLI merged 1 commit intoNov 28, 2026
Merged
Conversation
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 apache#22304 Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Swatantra Yadav <[email protected]>
|
xiaoxiang781216
approved these changes
Nov 27, 2026
GUIDINGLI
approved these changes
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Issue #22304
When EP_SUBMIT() on bulk IN or interrupt IN fails (e.g. endpoint is shut down due to cable disconnection, host 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: data written to the device remains in the xmit buffer and never reaches the host.
This change returns wrcontainer to priv->txfree via sq_addlast() and restores priv->nwrq++ across all three submission error paths:
Impact
Testing
Before and After Comparison
Verification Logs
Build verification:
Configuration: stm32f103-minimum:usbnsh (ARM Cortex-M3, arm-none-eabi-gcc 14.2.1)
Code style check: