All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	guille.rodriguez@gmail.com, lgirdwood@gmail.com
Subject: [PATCH 1/2] ASoC: ops: Fix bounds check for _sx controls
Date: Fri, 25 Nov 2022 15:48:36 +0000	[thread overview]
Message-ID: <20221125154837.1270501-2-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20221125154837.1270501-1-ckeepax@opensource.cirrus.com>

From: Mark Brown <broonie@kernel.org>

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: 4f1e50d6a9cf ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()")
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/soc-ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index bd88de0563583..47691119306fb 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -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;
-- 
2.30.2


  reply	other threads:[~2022-11-25 15:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25 15:48 [PATCH 0/2] SX control bounds check fixups Charles Keepax
2022-11-25 15:48 ` Charles Keepax [this message]
2022-11-25 15:48 ` [PATCH 2/2] ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx() Charles Keepax
2022-11-25 15:52 ` [PATCH 0/2] SX control bounds check fixups Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2022-05-11 13:41 [PATCH 1/2] ASoC: ops: Fix bounds check for _sx controls Mark Brown
2022-05-12 14:12 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221125154837.1270501-2-ckeepax@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=guille.rodriguez@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=patches@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.