From: Marek Vasut <marex@denx.de>
To: alsa-devel@alsa-project.org
Cc: Marek Vasut <marex@denx.de>, Mark Brown <broonie@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min
Date: Tue, 15 Feb 2022 14:06:45 +0100 [thread overview]
Message-ID: <20220215130645.164025-1-marex@denx.de> (raw)
While the $val/$val2 values passed in from userspace are always >= 0
integers, the limits of the control can be signed integers and the $min
can be non-zero and less than zero. To correctly validate $val/$val2
against platform_max, add the $min offset to val first.
Fixes: 817f7c9335ec0 ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
sound/soc/soc-ops.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index f24f7354f46fe..6389a512c4dc6 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -317,7 +317,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
mask = BIT(sign_bit + 1) - 1;
val = ucontrol->value.integer.value[0];
- if (mc->platform_max && val > mc->platform_max)
+ if (mc->platform_max && ((int)val + min) > mc->platform_max)
return -EINVAL;
if (val > max - min)
return -EINVAL;
@@ -330,7 +330,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
val = val << shift;
if (snd_soc_volsw_is_stereo(mc)) {
val2 = ucontrol->value.integer.value[1];
- if (mc->platform_max && val2 > mc->platform_max)
+ if (mc->platform_max && ((int)val2 + min) > mc->platform_max)
return -EINVAL;
if (val2 > max - min)
return -EINVAL;
--
2.34.1
next reply other threads:[~2022-02-15 13:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-15 13:06 Marek Vasut [this message]
2022-02-16 18:01 ` [PATCH] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min Mark Brown
2022-02-23 14:55 ` Takashi Iwai
2022-02-23 16:32 ` Mark Brown
2022-02-23 16:44 ` Takashi Iwai
2022-02-23 16:52 ` Marek Vasut
2022-05-16 23:53 ` Tan N.
2022-05-17 1:12 ` [PATCH] ASoC: ops: Fix the bounds checking in snd_soc_put_volsw_sx and snd_soc_put_xr_sx Tan Nayir
2022-05-17 13:04 ` Mark Brown
2022-05-17 14:25 ` Tan Nayır
2022-05-17 18:20 ` Mark Brown
2022-05-17 19:58 ` Tan Nayır
2022-05-18 12:07 ` Mark Brown
2022-05-18 23:56 ` Tan Nayır
2022-05-19 15:47 ` 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=20220215130645.164025-1-marex@denx.de \
--to=marex@denx.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).