usb: gadget: f_fs: Fix unbalanced spinlock in __ffs_ep0_queue_wait
authorUdipto Goswami <quic_ugoswami@quicinc.com>
Tue, 24 Jan 2023 09:11:49 +0000 (14:41 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jan 2023 17:19:39 +0000 (18:19 +0100)
commit921deb9da15851425ccbb6ee409dc2fd8fbdfe6b
treeb66637def42bf42f3f4b659df3cf41f33b1f1a6b
parenteb320f76e31dc835b9f57f04af1a2353b13bb7d8
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: 6a19da111057 ("usb: gadget: f_fs: Prevent race during ffs_ep0_queue_wait")
Reviewed-by: John Keeping <john@metanate.com>
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
Link: https://lore.kernel.org/r/20230124091149.18647-1-quic_ugoswami@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_fs.c