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>
This commit is contained in:
Sudheer Papothi 2016-01-29 02:10:46 +05:30 committed by David Keitel
parent c1ba99c89b
commit a3dd24f2ca

View file

@ -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;
}