diff mbox series

[1/2] ASoC: ops: Fix bounds check for _sx controls

Message ID 20220511134137.169575-1-broonie@kernel.org
State Accepted
Commit 698813ba8c580efb356ace8dbf55f61dac6063a8
Headers show
Series [1/2] ASoC: ops: Fix bounds check for _sx controls | expand

Commit Message

Mark Brown May 11, 2022, 1:41 p.m. UTC
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: 4f1e50d6a9cf9c1b ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()")
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown May 12, 2022, 2:12 p.m. UTC | #1
On Wed, 11 May 2022 14:41:36 +0100, Mark Brown wrote:
> 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.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: ops: Fix bounds check for _sx controls
      commit: 698813ba8c580efb356ace8dbf55f61dac6063a8
[2/2] ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()
      commit: 97eea946b93961fffd29448dcda7398d0d51c4b2

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index e693070f51fe..1ac7e2ce31a1 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -435,7 +435,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;