Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp249908ybd; Tue, 25 Jun 2019 20:44:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsd4UStg9SssI/Abek4igKAMRgsJMJlO5Y7+jZZTK6rrEvsgoSi93J93YHVBFegXXXnzja X-Received: by 2002:a17:90a:778c:: with SMTP id v12mr1668303pjk.141.1561520651135; Tue, 25 Jun 2019 20:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520651; cv=none; d=google.com; s=arc-20160816; b=N+BwM0W1dHl33lGK5YhzrJ90KvvoS//YAarNK/H0Rt5vU5rYygNDxSd4LfZLuWdof2 QQBvgTWY3VcNNgq4sJ1/TeZ0VnxbyPWjz+swrCzIirXBo0OZp0qdSlGKpgn3eaLM6RkS BeDXRC2X+rgxLxnWlkwJioCkiFGrowMn4WCKwysRBT+sPmsx1Rih8QPFU04sJkxhadLq gDCuXkLKze370tdIl6RumEeiGnN1BONXUyFnMIDg2JI6YHIiq6pv7UXGsbX0lTwXLYMZ 4sEN0RcQdq9tKNdvICtNARq+L7A/Kn3KoI8Ec2HKkZxnkQ4TRUyxdC2c+1bdHoDC2CDo HiQg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BtmotC71z5+G5Pn7h/GyJTOGx8U15cKGDDej5Ty2itI=; b=KrmpUO5bXOcmP5XiWfdaYjBjMfrES1gvh2Kilce1pBAM6UwyCdPwG5YGcbJ4whO2IP 4PhLgM5QR9h9WKRLL/CjaWINOgGntJYhtrlJGzXvdFS+FJSEYQyjza+csgr/2sDz5x0h LgDGpuL3861T/NOB6gqbLE410ikGlZsObxpq6c+9dpyhcQOOGbm9xAvIX3//nOquGboj S8sApOqUS63WvaslRlPqmwcWUEh4Yu2ZhWXw0X5Ywd+bz+PUDQNOJ4KipmG6xGb8pLXu UD/k3p2J6FoDm0+bc4EnCB93NBq6TGKfPBZi45iS72Af4FY5fxZdKflvxgMFOr5PDtlw oEzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZQwoz8ML; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k29si15147397pgl.157.2019.06.25.20.43.55; Tue, 25 Jun 2019 20:44:11 -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=ZQwoz8ML; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727264AbfFZDnL (ORCPT + 99 others); Tue, 25 Jun 2019 23:43:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:54130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727232AbfFZDnD (ORCPT ); Tue, 25 Jun 2019 23:43:03 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 768F4216E3; Wed, 26 Jun 2019 03:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520582; bh=xjOj61j8dRKenT4sBMAUHgMw5sjHvxeGq/Du6LnwnSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQwoz8MLt4hfJYY2jgTlsw3hHT0vPHA5swl2Ui3cBENL3K3qYUWM0MmLlOpDlJZoj ct9xtnophgKzkin+Q/yZO9uGwNj1aSQxawEA3+dtA5CLwddspC0UOrDbnGB3hy53KH uCLNO8aVdTYux4Z+dtsc9k9R962VfHClH/RZjF04= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ranjani Sridharan , "kernelci . org bot" , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.1 38/51] ASoC: core: Fix deadlock in snd_soc_instantiate_card() Date: Tue, 25 Jun 2019 23:40:54 -0400 Message-Id: <20190626034117.23247-38-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ranjani Sridharan [ 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