Skip to content

Commit 97eea94

Browse files
committed
ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()
The bounds checks in snd_soc_put_volsw_sx() are only being applied to the first channel, meaning it is possible to write out of bounds values to the second channel in stereo controls. Add appropriate checks. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 698813b commit 97eea94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sound/soc/soc-ops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,12 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
451451

452452
val_mask = mask << rshift;
453453
val2 = (ucontrol->value.integer.value[1] + min) & mask;
454+
455+
if (mc->platform_max && val2 > mc->platform_max)
456+
return -EINVAL;
457+
if (val2 > max)
458+
return -EINVAL;
459+
454460
val2 = val2 << rshift;
455461

456462
err = snd_soc_component_update_bits(component, reg2, val_mask,

0 commit comments

Comments
 (0)