From: Jaegyun Lee <dreams200260@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Neill Kapron <nkapron@google.com>
Cc: Jaegyun Lee <dreams200260@gmail.com>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH 2/2] usb: gadget: f_tcm: complete the Bulk-Only Reset status stage
Date: Sun, 29 Nov 2026 22:47:52 +0900 [thread overview]
Message-ID: <20261129134752.422736-2-dreams200260@gmail.com> (raw)
In-Reply-To: <20261129134752.422736-1-dreams200260@gmail.com>
The US_BULK_RESET_REQUEST case of usbg_bot_setup() ends with
bot_enqueue_cmd_cbw(fu);
return 0;
and never queues anything on ep0. composite_setup() leaves the status
stage of a class request to the function's ->setup(), as the
US_BULK_GET_MAX_LUN case right above does. The host never sees the
reset complete and the control transfer times out. The request type,
wValue and wLength of the reset request are not checked either.
Reproduced: a Bulk-Only Mass Storage Reset
(bmRequestType 0x21, bRequest 0xff, wLength 0) to a tcm BOT function
fails with ETIMEDOUT:
[ 46.051694][ T9631] usb 1-1: usbfs: USBDEVFS_CONTROL failed cmd tcm_bot_reset rqt 33 rq 255 len 0 ret -110
Check the request format and queue the zero-length status stage.
Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT")
Cc: stable@vger.kernel.org
Assisted-by: ZCode:GLM-5.4
Signed-off-by: Jaegyun Lee <dreams200260@gmail.com>
---
drivers/usb/gadget/function/f_tcm.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index f7dc09f4021de..c46d48cc348ce 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -466,6 +466,10 @@ static int usbg_bot_setup(struct usb_function *f,
return usb_ep_queue(cdev->gadget->ep0, cdev->req, GFP_ATOMIC);
case US_BULK_RESET_REQUEST:
+ if (ctrl->bRequestType != (USB_DIR_OUT | USB_TYPE_CLASS |
+ USB_RECIP_INTERFACE) || w_value || w_length)
+ return -EINVAL;
+
bot_dequeue_req(fu->ep_in, fu->bot_req_in);
bot_dequeue_req(fu->ep_out, fu->bot_req_out);
bot_dequeue_req(fu->ep_in, fu->bot_status.req);
@@ -475,7 +479,9 @@ static int usbg_bot_setup(struct usb_function *f,
}
bot_enqueue_cmd_cbw(fu);
- return 0;
+
+ cdev->req->length = 0;
+ return usb_ep_queue(cdev->gadget->ep0, cdev->req, GFP_ATOMIC);
}
return -ENOTSUPP;
}
prev parent reply other threads:[~2026-11-29 13:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:47 [PATCH 1/2] usb: gadget: f_tcm: dequeue data requests on Bulk-Only Reset Jaegyun Lee
2026-11-29 13:47 ` Jaegyun Lee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129134752.422736-2-dreams200260@gmail.com \
--to=dreams200260@gmail.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox