Skip to content

Commit

Permalink
ASoC: ops: Fix bounds check for _sx controls
Browse files Browse the repository at this point in the history
[ Upstream commit 698813b ]

For _sx controls the semantics of the max field is not the usual one, max
is the number of steps rather than the maximum value. This means that our
check in snd_soc_put_volsw_sx() needs to just check against the maximum
value.

Fixes: 4f1e50d ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()")
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220511134137.169575-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
broonie authored and gregkh committed Dec 8, 2022
1 parent c52d0c8 commit 325d94d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/soc-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
val = ucontrol->value.integer.value[0];
if (mc->platform_max && val > mc->platform_max)
return -EINVAL;
if (val > max - min)
if (val > max)
return -EINVAL;
val_mask = mask << shift;
val = (val + min) & mask;
Expand Down

0 comments on commit 325d94d

Please sign in to comment.