Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7150800ybi; Mon, 8 Jul 2019 15:40:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEUZ2uCSE56jxpcVLVc/6OeenkLTYxW5OA/vCesdOJZLNRl/1wl6gfA56KZ5l0CWjRftc0 X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr28148564plp.168.1562625607797; Mon, 08 Jul 2019 15:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625607; cv=none; d=google.com; s=arc-20160816; b=uyWN4LnaTVuqP1bi6QdyYujTd0cUtz5CXyXWobL/6qORF2RMHG1CfftkqO85KI8IQb 2SQKSeZnIdxTtsQ3zSfTK75XEzurr8812t17ZVW7Bi9Q/ql5lvuJ47bbX8IRWZ5KSKS2 9dUnatPSMzLZTHFWDYFM/Ekg24w9kweBSBOYSI53lZpQCCcD0+rLkPNYJ48x9+pEIhie DS/tHFcRVcEHXZpBoHRiQ92yvoWxhP/Oft1H1sCbly3bXjpNIevvbhimFDcoRok89k3i XkJ4zKKUyJ1QyinwgD+rZ3G5tIuZAWdTpXRzCPS7ktYCpohc92AuFCWOcjdIrBrT7tkd f7Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DOFGCxIwtL3vky4baRl0uSuovztdzrlTCtWoqyb3RHg=; b=mgmn9p+U1HEFd7V4rTUGx3FU1p2j9kbxNJPJqK5OTntZontz3G8X8bzWdxRrqtL6Cu c+ldA4c9g5pozcg9SPU4C8Yo9/5lEQpOsso73letA4EA1iFFi8x0iRNxVBnthC7+w3lL raNzENSBFHnHA2orpbe9qSB0iwu+Zjwg+h6kbyuLI5qqueAYrYhx5iX6IuxM9tvpQF8L rQO5BeWM/75wkBmYxPlu91jHwG8grfIE6wY0gDMoaxH9oSZTiGIa9g/v4hz/niomoRfY 6p+hKFISOY4vCWMxLHKGF4IwI5AAsNodjXoNd3uqEw/4MvRhj07oaqegrnmY73JYJ4zF /7dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o0YPyVK6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si5902046plj.194.2019.07.08.15.39.53; Mon, 08 Jul 2019 15:40:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o0YPyVK6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390690AbfGHPfx (ORCPT + 99 others); Mon, 8 Jul 2019 11:35:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390867AbfGHPfC (ORCPT ); Mon, 8 Jul 2019 11:35:02 -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 1DD6020665; Mon, 8 Jul 2019 15:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562600101; bh=8atBNu46beg+VWS2TbE2mQKXdNdpnS6fAWsFMrBMSoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o0YPyVK6UICLAkEPQqynmpYWG5ynJh4HjmXBLqWqqDPqd1uRNva0LHAnzFG8zHDd+ H2FjvgzPTN8OB2jMznXPE4pwWtE8jfG9Wi0ZIhj+Q4fM9SJyjztbsAdz8CPI2+lF6X dF+bK8HCX+WTfDy1uVm8FnTRwL19iKUWpOFo7c4U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "kernelci.org bot" , Ranjani Sridharan , Mark Brown , Sasha Levin Subject: [PATCH 5.1 42/96] ASoC: core: Fix deadlock in snd_soc_instantiate_card() Date: Mon, 8 Jul 2019 17:13:14 +0200 Message-Id: <20190708150528.822507752@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150526.234572443@linuxfoundation.org> References: <20190708150526.234572443@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 [ Upstream commit 495f926c68ddb905a7a0192963096138c6a934e1 ] Move the client_mutex lock to snd_soc_unbind_card() before removing link components. This prevents the deadlock in the error path in snd_soc_instantiate_card(). Fixes: 34ac3c3eb8 (ASoC: core: lock client_mutex while removing link components) Reported-by: kernelci.org bot Signed-off-by: Ranjani Sridharan Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9df3bdeb5c47..c010cc864cf3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1008,14 +1008,12 @@ static void soc_remove_link_components(struct snd_soc_card *card, struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; - mutex_lock(&client_mutex); for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; if (component->driver->remove_order == order) soc_remove_component(component); } - mutex_unlock(&client_mutex); } static void soc_remove_dai_links(struct snd_soc_card *card) @@ -2836,12 +2834,14 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) snd_soc_dapm_shutdown(card); snd_soc_flush_all_delayed_work(card); + mutex_lock(&client_mutex); /* remove all components used by DAI links on this card */ for_each_comp_order(order) { for_each_card_rtds(card, rtd) { soc_remove_link_components(card, rtd, order); } } + mutex_unlock(&client_mutex); soc_cleanup_card_resources(card); if (!unregister) -- 2.20.1