From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 500DFC433E7 for ; Mon, 20 Jul 2020 15:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D19C2064B for ; Mon, 20 Jul 2020 15:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595260084; bh=DtlKJ9x7CcQEvvENRNWdxDrLpZ+fk0WQa30+9bvzDcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BrnjkI9BbD0r/jQCW+4FsRX16gX+Geleq+GmI9R65xdb5uaVFJA1sq6TbrrS9VhSS 3u1wINEpyiQsK+6RaIZ1QL8kZpoYXqwdYiNAHiWt2JoOJHAOkkP7Vwq5G6fPnAVVIs PPu25FH+oXUr0+L6/zGjqWesqFrtpbd7bYPsgr44= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730853AbgGTPsC (ORCPT ); Mon, 20 Jul 2020 11:48:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:43478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730845AbgGTPsA (ORCPT ); Mon, 20 Jul 2020 11:48:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F23392064B; Mon, 20 Jul 2020 15:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595260080; bh=DtlKJ9x7CcQEvvENRNWdxDrLpZ+fk0WQa30+9bvzDcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j30uO/EczEyMKKveDmopL5ahsmxgqD0B7NC+a/MDgL44z9vVWGDj32XCu/wMsRbF0 a0qEvN/pjfZr1lbz2rmTnVcOjUDI8JAJTZIiiHlxLlXE2OEFwiHjc2VGUmYqfeGH5m i/QJepEup9ZttURPGk2UnuL/7QGUsjXzCJf2jOLs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qiang , Felipe Balbi Subject: [PATCH 4.14 100/125] usb: gadget: function: fix missing spinlock in f_uac1_legacy Date: Mon, 20 Jul 2020 17:37:19 +0200 Message-Id: <20200720152807.847643973@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720152802.929969555@linuxfoundation.org> References: <20200720152802.929969555@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qiang commit 8778eb0927ddcd3f431805c37b78fa56481aeed9 upstream. 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 Signed-off-by: Zhang Qiang Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_uac1_legacy.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/gadget/function/f_uac1_legacy.c +++ b/drivers/usb/gadget/function/f_uac1_legacy.c @@ -339,7 +339,9 @@ static int f_audio_out_ep_complete(struc /* 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(©_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))