Skip to content

Commit 0aea736

Browse files
crwulffgregkh
authored andcommitted
usb: gadget: f_fs: Fix a race condition when processing setup packets.
If the USB driver passes a pointer into the TRB buffer for creq, this buffer can be overwritten with the status response as soon as the event is queued. This can make the final check return USB_GADGET_DELAYED_STATUS when it shouldn't. Instead use the stored wLength. Fixes: 4d644ab ("usb: gadget: f_fs: Only return delayed status when len is 0") Cc: stable <[email protected]> Signed-off-by: Chris Wulff <[email protected]> Link: https://lore.kernel.org/r/CO1PR17MB5419BD664264A558B2395E28E1112@CO1PR17MB5419.namprd17.prod.outlook.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a4b46d4 commit 0aea736

File tree

1 file changed

+1
-1
lines changed
  • drivers/usb/gadget/function

1 file changed

+1
-1
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3811,7 +3811,7 @@ static int ffs_func_setup(struct usb_function *f,
38113811
__ffs_event_add(ffs, FUNCTIONFS_SETUP);
38123812
spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags);
38133813

3814-
return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
3814+
return ffs->ev.setup.wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
38153815
}
38163816

38173817
static bool ffs_func_req_match(struct usb_function *f,

0 commit comments

Comments
 (0)