All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] usb: gadget: function: fix missing spinlock in f_uac1_legacy
@ 2020-07-06  5:14 qiang.zhang
  2020-07-10 14:03 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: qiang.zhang @ 2020-07-06  5:14 UTC (permalink / raw)
  To: balbi; +Cc: colin.king, gregkh, linux-usb, linux-kernel, stable

From: Zhang Qiang <qiang.zhang@windriver.com>

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>
---
 v1->v2->v3->v4:
 Add changelog text and Cc tags, Fixes tags.

 drivers/usb/gadget/function/f_uac1_legacy.c | 2 ++
 1 file changed, 2 insertions(+)

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))
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] usb: gadget: function: fix missing spinlock in f_uac1_legacy
  2020-07-06  5:14 [PATCH v4] usb: gadget: function: fix missing spinlock in f_uac1_legacy qiang.zhang
@ 2020-07-10 14:03 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-07-10 14:03 UTC (permalink / raw)
  To: Sasha Levin, qiang.zhang, Zhang Qiang, balbi
  Cc: colin.king, gregkh, stable, stable

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: c6994e6f067c ("USB: gadget: add USB Audio Gadget driver").

The bot has tested the following trees: v5.7.7, v5.4.50, v4.19.131, v4.14.187, v4.9.229, v4.4.229.

v5.7.7: Build OK!
v5.4.50: Build OK!
v4.19.131: Build OK!
v4.14.187: Build OK!
v4.9.229: Failed to apply! Possible dependencies:
    Unable to calculate

v4.4.229: Failed to apply! Possible dependencies:
    Unable to calculate


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-10 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06  5:14 [PATCH v4] usb: gadget: function: fix missing spinlock in f_uac1_legacy qiang.zhang
2020-07-10 14:03 ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.