aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2014-08-08 11:29:35 -0400
committerMark Brown <broonie@linaro.org>2014-08-11 15:01:13 -0400
commit6912831623c5bbd38c6c26039d5f821557e5f541 (patch)
treee3b85d99c34d370673252b22a4800afb0d0bdb07 /sound/soc
parentae34a78c430c37c06404f032fb04e51315204281 (diff)
ASoC: dapm: Fix uninitialized variable in snd_soc_dapm_get_enum_double()
If soc_dapm_read() fails, reg_val will be uninitialized, and bogus values will be written later: sound/soc/soc-dapm.c: In function 'snd_soc_dapm_get_enum_double': sound/soc/soc-dapm.c:2862:15: warning: 'reg_val' may be used uninitialized in this function [-Wmaybe-uninitialized] unsigned int reg_val, val; ^ Return early on error to fix this. Introduced by commit ce0fc93ae56e2ba50ff8c220d69e4e860e889320 ("ASoC: Add DAPM support at the component level"). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-dapm.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8348352dc2c6..177bd8639ef9 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2860,12 +2860,14 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
2860 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); 2860 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
2861 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2861 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2862 unsigned int reg_val, val; 2862 unsigned int reg_val, val;
2863 int ret = 0;
2864 2863
2865 if (e->reg != SND_SOC_NOPM) 2864 if (e->reg != SND_SOC_NOPM) {
2866 ret = soc_dapm_read(dapm, e->reg, &reg_val); 2865 int ret = soc_dapm_read(dapm, e->reg, &reg_val);
2867 else 2866 if (ret)
2867 return ret;
2868 } else {
2868 reg_val = dapm_kcontrol_get_value(kcontrol); 2869 reg_val = dapm_kcontrol_get_value(kcontrol);
2870 }
2869 2871
2870 val = (reg_val >> e->shift_l) & e->mask; 2872 val = (reg_val >> e->shift_l) & e->mask;
2871 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); 2873 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val);
@@ -2875,7 +2877,7 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
2875 ucontrol->value.enumerated.item[1] = val; 2877 ucontrol->value.enumerated.item[1] = val;
2876 } 2878 }
2877 2879
2878 return ret; 2880 return 0;
2879} 2881}
2880EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); 2882EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
2881 2883