Otherwise it'd lead to negative array index read. Spotted by coverity CIDs 143182, 143184.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/soc/codecs/max98095.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 8fb072455802..bffcf4e6a2a2 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -1740,6 +1740,8 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, int fs, best, best_val, i; int regmask, regsave;
+ if (channel < 0) + return channel; BUG_ON(channel > 1);
if (!pdata || !max98095->eq_textcnt) @@ -1798,6 +1800,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 (channel < 0) + return channel; cdata = &max98095->dai[channel]; ucontrol->value.enumerated.item[0] = cdata->eq_sel;