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 --- 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; }