summaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorSudheer Papothi <spapothi@codeaurora.org>2016-01-29 02:10:46 +0530
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:10:10 -0700
commita3dd24f2caefae6824bf0fe983bb1444b9092d33 (patch)
treef3c2d84816db4805ff12b68d2816e2cfc20de4eb /sound/soc/soc-dapm.c
parentc1ba99c89b684b32bac0eb7c787e83c2ccb7d76f (diff)
ASoC: dapm: fix race condition in dapm
Dirty widget list can be accessed by multiple paths in dapm framework. Dirty list is protected by dapm mutex. Since dapm_force_enable_pin function accesses the dirty list, protect it using the dapm mutex. Signed-off-by: Aviral Gupta <aviralg@codeaurora.org> Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org> Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 90bf383fc603..58bca9a96b61 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1787,7 +1787,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
lockdep_assert_held(&card->dapm_mutex);
trace_snd_soc_dapm_start(card);
- mutex_lock(&dapm->card->dapm_power_mutex);
+ mutex_lock(&card->dapm_power_mutex);
list_for_each_entry(d, &card->dapm_list, list) {
if (dapm_idle_bias_off(d))
@@ -1906,7 +1906,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
pop_dbg(card->dev, card->pop_time,
"DAPM sequencing finished, waiting %dms\n", card->pop_time);
pop_wait(card->pop_time);
- mutex_unlock(&dapm->card->dapm_power_mutex);
+ mutex_unlock(&card->dapm_power_mutex);
trace_snd_soc_dapm_done(card);
@@ -4024,8 +4024,10 @@ int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
{
struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
+ mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (!w) {
dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin);
+ mutex_unlock(&dapm->card->dapm_mutex);
return -EINVAL;
}
@@ -4041,6 +4043,7 @@ int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
}
w->force = 1;
dapm_mark_dirty(w, "force enable");
+ mutex_unlock(&dapm->card->dapm_mutex);
return 0;
}