usb: gadget: f_tcm: Stall on invalid CBW

If the BOT command CBW is invalid, make sure to respond by setting
status endpoint STALL until the next proper CBW or reset.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/96022e2d5225f01a20263a4ba9c2e2c8a63328b8.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Thinh Nguyen
2024-12-24 08:56:07 +01:00
committed by Greg Kroah-Hartman
parent 29ed170538
commit a4d7274d07
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -287,8 +287,17 @@ static void bot_cmd_complete(struct usb_ep *ep, struct usb_request *req)
return;
ret = bot_submit_command(fu, req->buf, req->actual);
if (ret)
if (ret) {
pr_err("%s(%d): %d\n", __func__, __LINE__, ret);
if (!(fu->flags & USBG_BOT_WEDGED))
usb_ep_set_wedge(fu->ep_in);
fu->flags |= USBG_BOT_WEDGED;
bot_enqueue_cmd_cbw(fu);
} else if (fu->flags & USBG_BOT_WEDGED) {
fu->flags &= ~USBG_BOT_WEDGED;
usb_ep_clear_halt(fu->ep_in);
}
}
static int bot_prepare_reqs(struct f_uas *fu)
@@ -442,6 +451,11 @@ static int usbg_bot_setup(struct usb_function *f,
case US_BULK_RESET_REQUEST:
/* XXX maybe we should remove previous requests for IN + OUT */
if (fu->flags & USBG_BOT_WEDGED) {
fu->flags &= ~USBG_BOT_WEDGED;
usb_ep_clear_halt(fu->ep_in);
}
bot_enqueue_cmd_cbw(fu);
return 0;
}
+1
View File
@@ -130,6 +130,7 @@ struct f_uas {
#define USBG_USE_STREAMS (1 << 2)
#define USBG_IS_BOT (1 << 3)
#define USBG_BOT_CMD_PEND (1 << 4)
#define USBG_BOT_WEDGED (1 << 5)
struct usbg_cdb cmd[USBG_NUM_CMDS];
struct usb_ep *ep_in;