Skip to contentSkip to conversation

usb: gadget: acm: do not requeue failed RX requests

PATCH Superseded nacht20-de 2 participants 2 messages Sep 27 – Oct 16 USB

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

nacht20-de

author
#0 lore raw

PATCH 1/1 usb: gadget: acm: do not requeue failed RX requests

acm_rx_complete() pushes the received data into the RX buffer and queues the request again, regardless of its completion status.

When an endpoint is disabled, the UDC gives back its queued requests with an error status such as -ESHUTDOWN. This happens when the ACM function is disabled on a bus reset or disconnect, or when the usbacm console is stopped. Requeueing such a request from its completion handler puts it back on the endpoint that is being flushed. With DWC3, dwc3_remove_requests() then gives the same request back again and again, usb_ep_disable() never returns, and gadget teardown stalls.

Return early for failed completions, as the fastboot and rockusb functions already do. A failed request carries no valid data. It is freed by acm_disable(), and acm_set_alt() queues a new one when the data interface is enabled again. Successful completions are handled as before.

Fixes fc2b399ac03b ("usb: gadget: Add CDC ACM function")
---
 drivers/usb/gadget/f_acm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/gadget/f_acm.c +3 -0
index b6c11d97a62..2ea54dfbe69 100644
@@ -293,6 +293,9 @@ static void acm_rx_complete(struct usb_ep *ep, struct usb_request *req)
 {
 	struct f_acm *f_acm = req->context;
 
+	if (req->status)
+		return;
+
 	buf_push(&f_acm->rx_buf, req->buf, req->actual);
 
 	/* Queue RX req again */
Signature · 1 line
2.55.0
#1 lore raw

Hi nacht20-de,

Thank you for the patch.

Quoted 11 lines · On Sun, Sep 27, 2026 at 18:27, nacht20-de <[email protected]> wrote:

acm_rx_complete() pushes the received data into the RX buffer and queues the request again, regardless of its completion status.

When an endpoint is disabled, the UDC gives back its queued requests with an error status such as -ESHUTDOWN. This happens when the ACM function is disabled on a bus reset or disconnect, or when the usbacm console is stopped. Requeueing such a request from its completion handler puts it back on the endpoint that is being flushed. With DWC3, dwc3_remove_requests() then gives the same request back again and again, usb_ep_disable() never returns, and gadget teardown stalls.

Quoted 8 lines

Return early for failed completions, as the fastboot and rockusb functions already do. A failed request carries no valid data. It is freed by acm_disable(), and acm_set_alt() queues a new one when the data interface is enabled again. Successful completions are handled as before.

Fixes fc2b399ac03b ("usb: gadget: Add CDC ACM function")

Similarly to the linux contributions
(for example: https://lore.kernel.org/all/asN83ijsjvnbTsmP@squawk/),

this (and the author) need to be your name.

The change looks fine to me, can you re-submit with your name?

Thanks !
Mattijs

Quoted 20 lines
---
 drivers/usb/gadget/f_acm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/gadget/f_acm.c +3 -0
index b6c11d97a62..2ea54dfbe69 100644
@@ -293,6 +293,9 @@ static void acm_rx_complete(struct usb_ep *ep, struct usb_request *req)
 {
 	struct f_acm *f_acm = req->context;
 
+	if (req->status)
+		return;
+
 	buf_push(&f_acm->rx_buf, req->buf, req->actual);
 
 	/* Queue RX req again */
Signature · 1 line
2.55.0