summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorZhang Qiang <qiang.zhang@windriver.com>2020-07-06 13:14:55 +0800
committerFelipe Balbi <balbi@kernel.org>2020-07-09 10:13:07 +0300
commit8778eb0927ddcd3f431805c37b78fa56481aeed9 (patch)
tree85026f1a38e98e0fddd01c9146604bb451048434 /drivers/usb
parent30517ffeb3bff842e1355cbc32f1959d9dbb5414 (diff)
usb: gadget: function: fix missing spinlock in f_uac1_legacy
Add a missing spinlock protection for play_queue, because the play_queue may be destroyed when the "playback_work" work func and "f_audio_out_ep_complete" callback func operate this paly_queue at the same time. Fixes: c6994e6f067cf ("USB: gadget: add USB Audio Gadget driver") Cc: stable <stable@vger.kernel.org> Signed-off-by: Zhang Qiang <qiang.zhang@windriver.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/function/f_uac1_legacy.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c b/drivers/usb/gadget/function/f_uac1_legacy.c
index 349deae7cabd..e2d7f69128a0 100644
--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -336,7 +336,9 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, struct usb_request *req)
/* Copy buffer is full, add it to the play_queue */
if (audio_buf_size - copy_buf->actual < req->actual) {
+ spin_lock_irq(&audio->lock);
list_add_tail(&copy_buf->list, &audio->play_queue);
+ spin_unlock_irq(&audio->lock);
schedule_work(&audio->playback_work);
copy_buf = f_audio_buffer_alloc(audio_buf_size);
if (IS_ERR(copy_buf))