Skip to content

Commit 4f1e50d

Browse files
committed
ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()
We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 817f7c9 commit 4f1e50d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sound/soc/soc-ops.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,15 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
423423
int err = 0;
424424
unsigned int val, val_mask;
425425

426+
val = ucontrol->value.integer.value[0];
427+
if (mc->platform_max && val > mc->platform_max)
428+
return -EINVAL;
429+
if (val > max - min)
430+
return -EINVAL;
431+
if (val < 0)
432+
return -EINVAL;
426433
val_mask = mask << shift;
427-
val = (ucontrol->value.integer.value[0] + min) & mask;
434+
val = (val + min) & mask;
428435
val = val << shift;
429436

430437
err = snd_soc_component_update_bits(component, reg, val_mask, val);

0 commit comments

Comments
 (0)