summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2022-05-20 01:31:26 +0300
committerMark Brown <broonie@kernel.org>2022-05-20 13:43:10 +0100
commitf7a344468105ef8c54086dfdc800e6f5a8417d3e (patch)
tree999d00070549f90d6e8f757aabd6bcf346265b55 /sound
parentaffa9983e7cbac8cbe2596975efacdbdf0eb18e9 (diff)
ASoC: max98090: Move check for invalid values before casting in max98090_put_enab_tlv()
Validation of signed input should be done before casting to unsigned int. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Suggested-by: Mark Brown <broonie@kernel.org> Fixes: 2fbe467bcbfc ("ASoC: max98090: Reject invalid values in custom control put()") Link: https://lore.kernel.org/r/1652999486-29653-1-git-send-email-khoroshilov@ispras.ru Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/max98090.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 48dcf071bb5a..576277a82d41 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -393,7 +393,8 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol,
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
unsigned int mask = (1 << fls(mc->max)) - 1;
- unsigned int sel = ucontrol->value.integer.value[0];
+ int sel_unchecked = ucontrol->value.integer.value[0];
+ unsigned int sel;
unsigned int val = snd_soc_component_read(component, mc->reg);
unsigned int *select;
int change;
@@ -414,8 +415,9 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol,
val = (val >> mc->shift) & mask;
- if (sel < 0 || sel > mc->max)
+ if (sel_unchecked < 0 || sel_unchecked > mc->max)
return -EINVAL;
+ sel = sel_unchecked;
change = *select != sel;
*select = sel;