summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wulff <Chris.Wulff@biamp.com>2024-04-23 21:02:15 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-05-17 12:51:03 +0300
commitbad094bd08270a381feb7b31a997dfb80ba933bb (patch)
tree358c0c62298d7e187d2d00e2087f2981c4c2c544
parent0bbb498b8e3e61acd3db09783a036a290aabed94 (diff)
downloadlinux-bad094bd08270a381feb7b31a997dfb80ba933bb.tar.xz
usb: gadget: f_fs: Fix a race condition when processing setup packets.
commit 0aea736ddb877b93f6d2dd8cf439840d6b4970a9 upstream. 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: 4d644abf2569 ("usb: gadget: f_fs: Only return delayed status when len is 0") Cc: stable <stable@kernel.org> Signed-off-by: Chris Wulff <chris.wulff@biamp.com> Link: https://lore.kernel.org/r/CO1PR17MB5419BD664264A558B2395E28E1112@CO1PR17MB5419.namprd17.prod.outlook.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/gadget/function/f_fs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 73ad9c3acc33..a4367a43cdd8 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3414,7 +3414,7 @@ static int ffs_func_setup(struct usb_function *f,
__ffs_event_add(ffs, FUNCTIONFS_SETUP);
spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags);
- return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
+ return ffs->ev.setup.wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
}
static bool ffs_func_req_match(struct usb_function *f,