Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc4479fb authored by Aviral Gupta's avatar Aviral Gupta
Browse files

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_set_pin and dapm_force_enable_pin function
accesses the dirty list, protect it using the dapm mutex.

CRs-Fixed: 637323
Change-Id: I8c265072083e142c0858b6cc7a983d07e7d75af0
Signed-off-by: default avatarAviral Gupta <aviralg@codeaurora.org>
parent c40a2a3d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2164,8 +2164,10 @@ static int snd_soc_dapm_set_pin(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_PCM);
	if (!w) {
		dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin);
		mutex_unlock(&dapm->card->dapm_mutex);
		return -EINVAL;
	}

@@ -2176,6 +2178,7 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
	if (status == 0)
		w->force = 0;

	mutex_unlock(&dapm->card->dapm_mutex);
	return 0;
}

@@ -3588,8 +3591,10 @@ int snd_soc_dapm_force_enable_pin(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_PCM);
	if (!w) {
		dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin);
		mutex_unlock(&dapm->card->dapm_mutex);
		return -EINVAL;
	}

@@ -3597,6 +3602,7 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
	w->connected = 1;
	w->force = 1;
	dapm_mark_dirty(w, "force enable");
	mutex_unlock(&dapm->card->dapm_mutex);

	return 0;
}