Skip to content

Commit

Permalink
ASoC: core: Fix deadlock in snd_soc_instantiate_card()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ranj063 authored and broonie committed Jun 10, 2019
1 parent 04268bf commit 495f926
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -2839,12 +2837,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)
Expand Down

0 comments on commit 495f926

Please sign in to comment.