yangsong8-a1 opened a new pull request, #21993:
URL: https://github.com/apache/nuttx/pull/21993
## Summary
Two concurrency fixes in the CDC/ACM class driver, both visible with
CONFIG_CDCACM_DISABLE_TXBUF=y:
- cdcacm_sndpacket() overwrote priv->wrcontainer with NULL after an
interrupt-time re-entry (wrcomplete -> inner sndpacket) had already
assigned a new container, leaking the container and losing data.
A local snapshot with a conditional write fixes the race.
- When txfree ran empty after EP_SUBMIT, xmit.buffer still pointed at
the submitted req->buf, so the serial layer kept writing into the
buffer the controller owns. xmit.buffer is now set to NULL so the
serial layer treats the FIFO as full.
- g_init_lock moves into cdcacm_classobject() to protect both call
paths, and cdcuart_txempty() sets priv->ispolling under priv->lock.
- cdcacm.c now includes <nuttx/mutex.h> directly instead of relying on
another header to pull it in.
## Impact
drivers/usbdev/cdcacm.c only. No API or Kconfig change. Behavior
changes only with CONFIG_CDCACM_DISABLE_TXBUF=y (default n).
## Testing
Ubuntu 22.04, arm-none-eabi-gcc 10.3. Builds with no new warnings:
- raspberrypi-pico-2:usbnsh (with and without
CONFIG_CDCACM_DISABLE_TXBUF=y)
sim:usbdev with SIM_USB_RAW_GADGET, dummy_hcd on the host:
- conn 1 (CDCACM+CDCECM), conn 0 (RNDIS) and conn 2 (CDCNCM)
composite gadgets all enumerate (cdc_acm -> ttyACM0, cdc_ether /
rndis_host / cdc_ncm -> usb0).
- With CONFIG_CDCACM_DISABLE_TXBUF=y, `echo USB-TX-OK-123456789 >
/dev/ttyACM0` in nsh is received unchanged on the host's
/dev/ttyACM0 (20 bytes). The write goes through the fixed
sndpacket() path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]