Skip to content

Commit f33bcc5

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: ops: Correct bounds check for second channel on SX controls
Currently the check against the max value for the control is being applied after the value has had the minimum applied and been masked. But the max value simply indicates the number of volume levels on an SX control, and as such should just be applied on the raw value. Fixes: 97eea94 ("ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()") Signed-off-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 81cb291 commit f33bcc5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sound/soc/soc-ops.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,16 +464,15 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
464464
ret = err;
465465

466466
if (snd_soc_volsw_is_stereo(mc)) {
467-
unsigned int val2;
468-
469-
val_mask = mask << rshift;
470-
val2 = (ucontrol->value.integer.value[1] + min) & mask;
467+
unsigned int val2 = ucontrol->value.integer.value[1];
471468

472469
if (mc->platform_max && val2 > mc->platform_max)
473470
return -EINVAL;
474471
if (val2 > max)
475472
return -EINVAL;
476473

474+
val_mask = mask << rshift;
475+
val2 = (val2 + min) & mask;
477476
val2 = val2 << rshift;
478477

479478
err = snd_soc_component_update_bits(component, reg2, val_mask,

0 commit comments

Comments
 (0)