diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-06-19 10:07:19 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-26 09:12:40 +0200 |
commit | 957834895a27fd6cb73883047f578201a4f1e4b4 (patch) | |
tree | 386049d5d3ae891ef22d4e2954f8a383c4358133 | |
parent | 3b12115f3a38f118aae79ccd4d59e33d444f7e68 (diff) | |
download | linux-stable-957834895a27fd6cb73883047f578201a4f1e4b4.tar.gz linux-stable-957834895a27fd6cb73883047f578201a4f1e4b4.tar.bz2 linux-stable-957834895a27fd6cb73883047f578201a4f1e4b4.zip |
ASoC: soc-core: call snd_soc_unbind_card() under mutex_lock;
[ Upstream commit b545542a0b866f7975254e41c595836e9bc0ff2f ]
commit 34ac3c3eb8f0c07 ("ASoC: core: lock client_mutex while removing
link components") added mutex_lock() at soc_remove_link_components().
Is is called from snd_soc_unbind_card()
snd_soc_unbind_card()
=> soc_remove_link_components()
soc_cleanup_card_resources()
soc_remove_dai_links()
=> soc_remove_link_components()
And, there are 2 way to call it.
(1)
snd_soc_unregister_component()
** mutex_lock()
snd_soc_component_del_unlocked()
=> snd_soc_unbind_card()
** mutex_unlock()
(2)
snd_soc_unregister_card()
=> snd_soc_unbind_card()
(1) case is already using mutex_lock() when it calles
snd_soc_unbind_card(), thus, we will get lockdep warning.
commit 495f926c68ddb90 ("ASoC: core: Fix deadlock in
snd_soc_instantiate_card()") tried to fixup it, but still not
enough. We still have lockdep warning when we try unbind/bind.
We need mutex_lock() under snd_soc_unregister_card()
instead of snd_remove_link_components()/snd_soc_unbind_card().
Fixes: 34ac3c3eb8f0c07 ("ASoC: core: lock client_mutex while removing link components")
Fixes: 495f926c68ddb90 ("ASoC: core: Fix deadlock in snd_soc_instantiate_card()")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | sound/soc/soc-core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c010cc864cf3..f05a5c0a8aff 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2834,14 +2834,12 @@ 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) @@ -2860,7 +2858,9 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) */ int snd_soc_unregister_card(struct snd_soc_card *card) { + mutex_lock(&client_mutex); snd_soc_unbind_card(card, true); + mutex_unlock(&client_mutex); dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); return 0; |