mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min
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: 817f7c9335
("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>
This commit is contained in:
parent
a887f9c7a4
commit
9bdd10d57a
1 changed files with 2 additions and 2 deletions
|
@ -319,7 +319,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
|
||||||
if (ucontrol->value.integer.value[0] < 0)
|
if (ucontrol->value.integer.value[0] < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
val = ucontrol->value.integer.value[0];
|
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;
|
return -EINVAL;
|
||||||
if (val > max - min)
|
if (val > max - min)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -332,7 +332,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
|
||||||
if (ucontrol->value.integer.value[1] < 0)
|
if (ucontrol->value.integer.value[1] < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
val2 = ucontrol->value.integer.value[1];
|
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;
|
return -EINVAL;
|
||||||
if (val2 > max - min)
|
if (val2 > max - min)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Reference in a new issue