Skip to content

Commit 9bdd10d

Browse files
Marek Vasutbroonie
authored andcommitted
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: 817f7c9 ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()") Signed-off-by: Marek Vasut <[email protected]> Cc: Mark Brown <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a887f9c commit 9bdd10d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/soc/soc-ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
319319
if (ucontrol->value.integer.value[0] < 0)
320320
return -EINVAL;
321321
val = ucontrol->value.integer.value[0];
322-
if (mc->platform_max && val > mc->platform_max)
322+
if (mc->platform_max && ((int)val + min) > mc->platform_max)
323323
return -EINVAL;
324324
if (val > max - min)
325325
return -EINVAL;
@@ -332,7 +332,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
332332
if (ucontrol->value.integer.value[1] < 0)
333333
return -EINVAL;
334334
val2 = ucontrol->value.integer.value[1];
335-
if (mc->platform_max && val2 > mc->platform_max)
335+
if (mc->platform_max && ((int)val2 + min) > mc->platform_max)
336336
return -EINVAL;
337337
if (val2 > max - min)
338338
return -EINVAL;

0 commit comments

Comments
 (0)