boot: zephyr: serial_adapter: fix CDC ACM data loss on line buffer exhaustion #2977
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 285 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.338
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #2977"
general
weight: 0.35
d3zd3z
Fixes #2949.
Problem
The non-RAW CDC ACM receive path in serial_adapter.c sizes
uart_fifo_read()batches by an estimate of free bytes, but completed lines consume whole line buffers. A batch containing more newline-terminated lines than free buffers hit thesys_slist_get(&avail_queue)failure path, logged "Not enough memory to store incoming data!" and returned — discarding the unconsumed tail of the already-read batch (those bytes were already out of the USB FIFO).Fix
rx_batch_off/rx_batch_len) instead of dropping the tail.boot_uart_fifo_getline(), under the existingirq_lock()— on the USB device-next stack the RX callback runs on a work-queue thread and can interleave with the caller without it.Plain UART and RAW protocol paths are unchanged. No heap, threads, or work items are added.
Testing
Serial recovery has no CI coverage, so this was validated on hardware (Raspberry Pi Pico W / RP2040, USB FS CDC ACM, SMP over console):
mcumgr image uploadstalled at 0.00% (3/3 attempts); 198/200 pipelined short SMP requests lost.Notes
The pre-existing RP2040 USB-device-stack wedge under fully pipelined floods reproduces on pristine upstream and is unaffected by this change (out of scope).
Thank you for taking the time to review this. Any feedback is very welcome — I'm glad to rework the approach or add anything that's missing.