ASoC: wm8994: check for array index returned
authorVinod Koul <vinod.koul@intel.com>
Tue, 28 May 2013 09:36:42 +0000 (15:06 +0530)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 28 May 2013 14:36:45 +0000 (15:36 +0100)
The array 'drc_cfg' of size 3 may use index value -22 (EINVAL)
The array 'retune_mobile_cfg' of size 3 may use index value -22 (EINVAL)

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/wm8994.c

index b38382cc4b591757082bd9942f421503dffa7237..dfd997aaadfca3077882c2bcd24e8d8f475cd70f 100644 (file)
@@ -383,6 +383,8 @@ static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol,
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        int drc = wm8994_get_drc(kcontrol->id.name);
 
+       if (drc < 0)
+               return drc;
        ucontrol->value.enumerated.item[0] = wm8994->drc_cfg[drc];
 
        return 0;
@@ -488,6 +490,9 @@ static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
 
+       if (block < 0)
+               return block;
+
        ucontrol->value.enumerated.item[0] = wm8994->retune_mobile_cfg[block];
 
        return 0;