Skip to content

Commit c7e65a3

Browse files
ranj063gregkh
authored andcommitted
ASoC: core: Fix deadlock in snd_soc_instantiate_card()
[ Upstream commit 495f926 ] 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: 34ac3c3 (ASoC: core: lock client_mutex while removing link components) Reported-by: kernelci.org bot <[email protected]> Signed-off-by: Ranjani Sridharan <[email protected]> Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 0a1c42c commit c7e65a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/soc/soc-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,14 +1008,12 @@ static void soc_remove_link_components(struct snd_soc_card *card,
10081008
struct snd_soc_component *component;
10091009
struct snd_soc_rtdcom_list *rtdcom;
10101010

1011-
mutex_lock(&client_mutex);
10121011
for_each_rtdcom(rtd, rtdcom) {
10131012
component = rtdcom->component;
10141013

10151014
if (component->driver->remove_order == order)
10161015
soc_remove_component(component);
10171016
}
1018-
mutex_unlock(&client_mutex);
10191017
}
10201018

10211019
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)
28362834
snd_soc_dapm_shutdown(card);
28372835
snd_soc_flush_all_delayed_work(card);
28382836

2837+
mutex_lock(&client_mutex);
28392838
/* remove all components used by DAI links on this card */
28402839
for_each_comp_order(order) {
28412840
for_each_card_rtds(card, rtd) {
28422841
soc_remove_link_components(card, rtd, order);
28432842
}
28442843
}
2844+
mutex_unlock(&client_mutex);
28452845

28462846
soc_cleanup_card_resources(card);
28472847
if (!unregister)

0 commit comments

Comments
 (0)