From: Mark Brown Date: Wed, 20 Apr 2022 19:34:53 +0000 (+0100) Subject: ASoC: max98090: Reject invalid values in custom control put() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ee46fbb0d2dbc965f66d2975e90b4f233a7c2920;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ASoC: max98090: Reject invalid values in custom control put() [ Upstream commit 2fbe467bcbfc760a08f08475eea6bbd4c2874319 ] The max98090 driver has a custom put function for some controls which can only be updated in certain circumstances which makes no effort to validate that input is suitable for the control, allowing out of spec values to be written to the hardware and presented to userspace. Fix this by returning an error when invalid values are written. Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20220420193454.2647908-1-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 3fe09828745a..a25183f6fba6 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -419,6 +419,9 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, val = (val >> mc->shift) & mask; + if (sel < 0 || sel > mc->max) + return -EINVAL; + *select = sel; /* Setting a volume is only valid if it is already On */