Commit 4b80b8c2 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: snd_soc_new_{mixer,mux,pga} make sure to use right DAPM context

Currently it is possible that snd_soc_new_{mixer,mux,pga} is called with a
DAPM context not matching the widgets context. This can lead to a wrong
prefix_len calculation, which will result in undefined behaviour. To avoid
this always use the DAPM context from the widget itself.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@kernel.org
parent 0cd114ff
...@@ -350,9 +350,9 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, ...@@ -350,9 +350,9 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm,
} }
/* create new dapm mixer control */ /* create new dapm mixer control */
static int dapm_new_mixer(struct snd_soc_dapm_context *dapm, static int dapm_new_mixer(struct snd_soc_dapm_widget *w)
struct snd_soc_dapm_widget *w)
{ {
struct snd_soc_dapm_context *dapm = w->dapm;
int i, ret = 0; int i, ret = 0;
size_t name_len, prefix_len; size_t name_len, prefix_len;
struct snd_soc_dapm_path *path; struct snd_soc_dapm_path *path;
...@@ -450,9 +450,9 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm, ...@@ -450,9 +450,9 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
} }
/* create new dapm mux control */ /* create new dapm mux control */
static int dapm_new_mux(struct snd_soc_dapm_context *dapm, static int dapm_new_mux(struct snd_soc_dapm_widget *w)
struct snd_soc_dapm_widget *w)
{ {
struct snd_soc_dapm_context *dapm = w->dapm;
struct snd_soc_dapm_path *path = NULL; struct snd_soc_dapm_path *path = NULL;
struct snd_kcontrol *kcontrol; struct snd_kcontrol *kcontrol;
struct snd_card *card = dapm->card->snd_card; struct snd_card *card = dapm->card->snd_card;
...@@ -535,8 +535,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm, ...@@ -535,8 +535,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
} }
/* create new dapm volume control */ /* create new dapm volume control */
static int dapm_new_pga(struct snd_soc_dapm_context *dapm, static int dapm_new_pga(struct snd_soc_dapm_widget *w)
struct snd_soc_dapm_widget *w)
{ {
if (w->num_kcontrols) if (w->num_kcontrols)
dev_err(w->dapm->dev, dev_err(w->dapm->dev,
...@@ -1826,13 +1825,13 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm) ...@@ -1826,13 +1825,13 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
case snd_soc_dapm_mixer: case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl: case snd_soc_dapm_mixer_named_ctl:
w->power_check = dapm_generic_check_power; w->power_check = dapm_generic_check_power;
dapm_new_mixer(dapm, w); dapm_new_mixer(w);
break; break;
case snd_soc_dapm_mux: case snd_soc_dapm_mux:
case snd_soc_dapm_virt_mux: case snd_soc_dapm_virt_mux:
case snd_soc_dapm_value_mux: case snd_soc_dapm_value_mux:
w->power_check = dapm_generic_check_power; w->power_check = dapm_generic_check_power;
dapm_new_mux(dapm, w); dapm_new_mux(w);
break; break;
case snd_soc_dapm_adc: case snd_soc_dapm_adc:
case snd_soc_dapm_aif_out: case snd_soc_dapm_aif_out:
...@@ -1845,7 +1844,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm) ...@@ -1845,7 +1844,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
case snd_soc_dapm_pga: case snd_soc_dapm_pga:
case snd_soc_dapm_out_drv: case snd_soc_dapm_out_drv:
w->power_check = dapm_generic_check_power; w->power_check = dapm_generic_check_power;
dapm_new_pga(dapm, w); dapm_new_pga(w);
break; break;
case snd_soc_dapm_input: case snd_soc_dapm_input:
case snd_soc_dapm_output: case snd_soc_dapm_output:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment