[PATCH] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min
Takashi Iwai
tiwai at suse.de
Wed Feb 23 15:55:54 CET 2022
On Tue, 15 Feb 2022 14:06:45 +0100,
Marek Vasut wrote:
>
> 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 at denx.de>
> Cc: Mark Brown <broonie at kernel.org>
> Cc: stable at vger.kernel.org
Now I'm looking at this since I pulled Mark's PR, and noticed that
snd_soc_put_volsw_sx() may have a similar problem. Care to cover
that, too?
But, more reading the code, I suspect whether the function does work
correctly at all... How is the mask calculation done in that way?
unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
What's the difference of this function with snd_soc_put_volsw()?
Furthermore, the mask calculation and usage in snd_soc_put_volsw()
isn't right, either, I'm afraid; if the range is [-10, 0], max=0, then
mask will 0, which will omit all values...
I guess we need to revisit those functions (or I need more coffee).
thanks,
Takashi
More information about the Alsa-devel
mailing list