diff options
author | Marek Vasut <marex@denx.de> | 2022-02-15 14:06:45 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-03-08 19:01:56 +0100 |
commit | 7e0e4bc93811cf600508ff36f07abea7b40643ed (patch) | |
tree | 8e27e058de75d71d81ac3ac0c883411cd66ce007 /sound | |
parent | d57c4e88b97d002b5df534541cf56bf9c6cb4792 (diff) | |
download | linux-stable-7e0e4bc93811cf600508ff36f07abea7b40643ed.tar.gz linux-stable-7e0e4bc93811cf600508ff36f07abea7b40643ed.tar.bz2 linux-stable-7e0e4bc93811cf600508ff36f07abea7b40643ed.zip |
ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min
commit 9bdd10d57a8807dba0003af0325191f3cec0f11c upstream.
While the $val/$val2 values passed in from userspace are always >= 0
integers, the limits of the control can be signed integers and the $min
can be non-zero and less than zero. To correctly validate $val/$val2
against platform_max, add the $min offset to val first.
Fixes: 817f7c9335ec0 ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220215130645.164025-1-marex@denx.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-ops.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 76bd264ee88d..d6d72595fbd0 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -328,7 +328,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, mask = BIT(sign_bit + 1) - 1; val = ucontrol->value.integer.value[0]; - if (mc->platform_max && val > mc->platform_max) + if (mc->platform_max && ((int)val + min) > mc->platform_max) return -EINVAL; if (val > max - min) return -EINVAL; @@ -341,7 +341,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, val = val << shift; if (snd_soc_volsw_is_stereo(mc)) { val2 = ucontrol->value.integer.value[1]; - if (mc->platform_max && val2 > mc->platform_max) + if (mc->platform_max && ((int)val2 + min) > mc->platform_max) return -EINVAL; if (val2 > max - min) return -EINVAL; |