Re: [PATCH] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
> Cc: Mark Brown <broonie@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx

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



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux