[alsa-devel] [PATCH 31/31] ASoC: max98095: Add missing negative channel checks
Takashi Iwai
tiwai at suse.de
Tue Nov 5 18:40:18 CET 2013
Otherwise it'd lead to negative array index read.
Spotted by coverity CIDs 143182, 143184.
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
sound/soc/codecs/max98095.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 67244315c721..a70f35cc652e 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -1743,7 +1743,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
int fs, best, best_val, i;
int regmask, regsave;
- if (WARN_ON(channel > 1))
+ if (WARN_ON(channel < 0 || channel > 1))
return -EINVAL;
if (!pdata || !max98095->eq_textcnt)
@@ -1802,6 +1802,8 @@ static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol,
int channel = max98095_get_eq_channel(kcontrol->id.name);
struct max98095_cdata *cdata;
+ if (WARN_ON(channel < 0 || channel > 1))
+ return -EINVAL;
cdata = &max98095->dai[channel];
ucontrol->value.enumerated.item[0] = cdata->eq_sel;
--
1.8.4.2
More information about the Alsa-devel
mailing list