ASoC: cs35l41: Add out of bound check for mixer

Program such as nanomix allows out of bound input
to mixer, which may crash kernel.

This issue is found by Google test (LENOVO-848).

Add out of bound check for mixer to prevent
kernel crash.

Mot-Crs-fixed:(CR)

Change-Id: I4c0437cfd2d2570a9c9489db500cffc513f27c43
Signed-off-by: Li Xu <li.xu@cirrus.com>
Reviewed-on: https://gerrit.mot.com/1253050
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Guobin Zhang <zhanggb@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1253083
This commit is contained in:
Li Xu 2018-09-26 11:04:40 -05:00 • committed by Yuesheng Huang
commit ae431b8af0

View file

@ -317,12 +317,17 @@ static int cs35l41_cspl_cmd_put(struct snd_kcontrol *kcontrol,
struct cs35l41_private *cs35l41 = snd_soc_codec_get_drvdata(codec);
struct soc_enum *soc_enum;
unsigned int i = ucontrol->value.enumerated.item[0];
int ret = 0;
soc_enum = (struct soc_enum *)kcontrol->private_value;
if (i >= soc_enum->items) {
dev_err(codec->dev, "Invalid mixer input (%u)\n", i);
return -EINVAL;
}
cs35l41->cspl_cmd = soc_enum->values[i];
return ret;
return 0;
}
static int cs35l41_cspl_cmd_get(struct snd_kcontrol *kcontrol,