summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2022-04-20 20:34:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-05-18 09:15:43 +0200
commit015a9f154ce17563af6cfa7da31b88be1967fb2b (patch)
treee1f2d24f0fb7f267794bef8d71b2f1b38176615d
parent0457a3c3a578e7636862aae4a7a9ed23592227f4 (diff)
downloadlinux-015a9f154ce17563af6cfa7da31b88be1967fb2b.tar.gz
linux-015a9f154ce17563af6cfa7da31b88be1967fb2b.tar.bz2
linux-015a9f154ce17563af6cfa7da31b88be1967fb2b.zip
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 <broonie@kernel.org> Link: https://lore.kernel.org/r/20220420193454.2647908-1-broonie@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--sound/soc/codecs/max98090.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index e7aef841f87d..4aefb13900c2 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 */