Skip to contentSkip to conversation

ASoC: TLV320AIC3X: Fix kcontrol's private value use in put callback

PATCH Applied Jarkko Nikula 2 participants 3 messages Feb 6, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: TLV320AIC3X: Fix kcontrol's private value use in put callback

From: Eero Nurkkala <[email protected]>

Function snd_soc_dapm_put_volsw_aic3x misuses the kcontrol's private value by still accessing it as bitfields even SOC_SINGLE_VALUE constructs it as a pointer into struct soc_mixer_control after the commit 4eaa9819dc08d7bfd1065ce530e31b18a119dcaf.

This was causing arbitrary register writes when touching the controls defined with SOC_DAPM_SINGLE_AIC3X.

---
 sound/soc/codecs/tlv320aic3x.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
sound/soc/codecs/tlv320aic3x.c +7 -4
index b47a749..aea0cb7 100644
@@ -165,10 +165,13 @@ 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);
-	int reg = kcontrol->private_value & 0xff;
-	int shift = (kcontrol->private_value >> 8) & 0x0f;
-	int mask = (kcontrol->private_value >> 16) & 0xff;
-	int invert = (kcontrol->private_value >> 24) & 0x01;
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	unsigned int reg = mc->reg;
+	unsigned int shift = mc->shift;
+	int max = mc->max;
+	unsigned int mask = (1 << fls(max)) - 1;
+	unsigned int invert = mc->invert;
 	unsigned short val, val_mask;
 	int ret;
 	struct snd_soc_dapm_path *path;
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 2/2 ASoC: WM8990: Fix kcontrol's private value use in put callback

Function wm899x_outpga_put_volsw_vu misuses the kcontrol's private value by still accessing it as bitfields even SOC_SINGLE_VALUE constructs it as a pointer into struct soc_mixer_control after the commit 4eaa9819dc08d7bfd1065ce530e31b18a119dcaf.

This is very similar fix than fix to TLV320AIC3X codec made by Eero Nurkkala <[email protected]>. This fix is compile tested only.

---
 sound/soc/codecs/wm8990.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
sound/soc/codecs/wm8990.c +3 -1
index 1cbb7b9..a5731fa 100644
@@ -176,7 +176,9 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	int reg = kcontrol->private_value & 0xff;
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	int reg = mc->reg;
 	int ret;
 	u16 val;
 
Signature · 1 line
1.5.6.5
Applied
#2 lore raw
In reply to Jarkko Nikula
Quoted 4 lines · Jarkko Nikula

Function snd_soc_dapm_put_volsw_aic3x misuses the kcontrol's private value by still accessing it as bitfields even SOC_SINGLE_VALUE constructs it as a pointer into struct soc_mixer_control after the commit 4eaa9819dc08d7bfd1065ce530e31b18a119dcaf.

Applied both, thanks.