Skip to content

Commit 921deb9

Browse files
Udipto Goswamigregkh
authored andcommitted
usb: gadget: f_fs: Fix unbalanced spinlock in __ffs_ep0_queue_wait
__ffs_ep0_queue_wait executes holding the spinlock of &ffs->ev.waitq.lock and unlocks it after the assignments to usb_request are done. However in the code if the request is already NULL we bail out returning -EINVAL but never unlocked the spinlock. Fix this by adding spin_unlock_irq &ffs->ev.waitq.lock before returning. Fixes: 6a19da1 ("usb: gadget: f_fs: Prevent race during ffs_ep0_queue_wait") Reviewed-by: John Keeping <[email protected]> Signed-off-by: Udipto Goswami <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eb320f7 commit 921deb9

File tree

1 file changed

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

1 file changed

+3
-1
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ static int __ffs_ep0_queue_wait(struct ffs_data *ffs, char *data, size_t len)
279279
struct usb_request *req = ffs->ep0req;
280280
int ret;
281281

282-
if (!req)
282+
if (!req) {
283+
spin_unlock_irq(&ffs->ev.waitq.lock);
283284
return -EINVAL;
285+
}
284286

285287
req->zero = len < le16_to_cpu(ffs->ev.setup.wLength);
286288

0 commit comments

Comments
 (0)