From: "Tan Nayır" <tannayir@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Marek Vasut <marex@denx.de>,
alsa-devel@alsa-project.org, stable@vger.kernel.org
Subject: Re: [PATCH] ASoC: ops: Fix the bounds checking in snd_soc_put_volsw_sx and snd_soc_put_xr_sx
Date: Thu, 19 May 2022 02:56:34 +0300 [thread overview]
Message-ID: <5a0e9339-5bdc-3e05-08f4-9137ebeb5ce5@gmail.com> (raw)
In-Reply-To: <YoThkxU9Q2cDrq4v@sirena.org.uk>
For a control defined like this:
-- SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40, digital_gain) --
This is what the snd_soc_info_volsw_sx reports:
$mc->platform_max:40, $mc->max:40, $mc->min:-84,
$uinfo->value.integer.max:40, $uinfo->value.integer.min:0
Now this is obviously wrong which is another issue which I'll explain a
bit later
but the mixer control($mc) limits are exactly the same inside
the snd_soc_put_volsw_sx function.
So the min and max fields inside the $mc are the same in
snd_soc_put_volsw_sx
so this means that the code without my patch has an incorrect check.
Here's an example, this is the check before the patch:
-- if (mc->platform_max && val > mc->platform_max) --
Let's say the userspace passes 50 as $val which should be within the
range of
0 to 124 so it is a valid value.
The check is done before the val is re-scaled, so it checks whether the val
is bigger than 40 which is the value of platform_max at that point.
Is the $mc->platform_max supposed to be set to the number of steps
as opposed to the maximum value?
Back to the first issue that I've mentioned in this message, the
snd_soc_info_volsw_sx
reports the wrong value because it adds the $mc->min to the value which
not necessary.
Curiously enough, there are actually two commits from 6 years ago
on the Qualcomm's fork of Linux that fix this one.
Neither of these commits exist on the upstream Linux kernel at the
moment. I've linked them below.
For the sake of integrity, all of the values that I've gathered from
debugging
were the same before and after applying these patches.
What I mean by that is that the only thing that changes when the patches
below are applied
is that the snd_soc_info_volsw_sx reports the correct range to the userspace
which should be 0 to 124.
Also the snd_soc_put_volsw_sx still checks the value from userspace
which has a range of 0 to 124 against the maximum of the signed range
which is from -84 to 40 regardless of the patches below.
65c7d020fbee8 ("ASoC: Update the Max value of integer controls.")
https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/commit/65c7d020fbee8070f33072291c32eef7584a56d4
0d873de90eb16 ("ASoC: sound: soc: fix incorrect max value")
https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/commit/0d873de90eb16e3af499eb87da1ed14440b788d5
next prev parent reply other threads:[~2022-05-18 23:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-15 13:06 [PATCH] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min Marek Vasut
2022-02-16 18:01 ` 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 [this message]
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=5a0e9339-5bdc-3e05-08f4-9137ebeb5ce5@gmail.com \
--to=tannayir@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=marex@denx.de \
--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).