ASoC: Fix wrong data type access in a few codec drivers
Subsystems (4)
PATCH 1/1 ASoC: Fix wrong data type access in a few codec drivers
Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol") changed the control private data type that is passed to snd_soc_cnew when creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type.
---
This was noted as a null pointer deference when trying to do mutex_lock in
tlv320aic3x: snd_soc_dapm_put_volsw_aic3x but I believe something similar could orrur also in wm8993 and wm8903 too.
--- sound/soc/codecs/tlv320aic3x.c | 3 ++- sound/soc/codecs/wm8903.c | 3 ++- sound/soc/codecs/wm8993.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
sound/soc/codecs/tlv320aic3x.c +2 -1
@@ -157,7 +157,8 @@ static int aic3x_read(struct snd_soc_codec *codec, unsigned int reg,static int snd_soc_dapm_put_volsw_aic3x (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct snd_soc_dapm_widget *widget =snd_kcontrol_chip (kcontrol); +struct snd_soc_dapm_widget_list *wlist =snd_kcontrol_chip (kcontrol); +struct snd_soc_dapm_widget *widget = wlist->widgets[0 ];struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;unsigned int reg = mc->reg;
sound/soc/codecs/wm8903.c +2 -1
@@ -382,7 +382,8 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm,static int wm8903_class_w_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct snd_soc_dapm_widget *widget =snd_kcontrol_chip (kcontrol); +struct snd_soc_dapm_widget_list *wlist =snd_kcontrol_chip (kcontrol); +struct snd_soc_dapm_widget *widget = wlist->widgets[0 ];struct snd_soc_codec *codec = widget->codec;struct wm8903_priv *wm8903 =snd_soc_codec_get_drvdata (codec);u16 reg;
sound/soc/codecs/wm8993.c +2 -1
@@ -718,7 +718,8 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w,static int class_w_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct snd_soc_dapm_widget *widget =snd_kcontrol_chip (kcontrol); +struct snd_soc_dapm_widget_list *wlist =snd_kcontrol_chip (kcontrol); +struct snd_soc_dapm_widget *widget = wlist->widgets[0 ];struct snd_soc_codec *codec = widget->codec;struct wm8993_priv *wm8993 =snd_soc_codec_get_drvdata (codec);int ret;
Signature · 1 line
1.7.0.4
Jarkko Nikula wrote at Friday, May 13, 2011 8:24 AM:
Quoted 9 lines
Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol")
changed the control private data type that is passed tosnd_soc_cnewwhen creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type.Signed-off-by Jarkko Nikula <[email protected]>Cc Stephen Warren <[email protected]>
Crap, sorry about that.
I think this needs to be fixed in a few more places:wm8994_put_hp_enumwm8994_put_class_wwm8995_put_class_w
based on: cd sound/soc && grep -HrnI snd_kcontrol_chip . ... and finding all those that look up widgets not a codec.
Otherwise, on Tegra+WM8903, I repro'd the bug, and tested the fix, so:
Signature · 1 line
nvpublic
Quoted 10 lines · On Fri, 13 May 2011 08:54:34 -0700 Stephen Warren <[email protected]> wrote:
Crap, sorry about that.
I think this needs to be fixed in a few more places:
wm8994_put_hp_enumwm8994_put_class_wwm8995_put_class_wbased on: cd
sound/soc&& grep -HrnIsnd_kcontrol_chip. ... and finding all those that look up widgets not a codec.
Thanks, I managed to not notice those. Will update shortly.
Signature · 1 line
Jarkko