Message ID | 20220119123101.GA9509@kili (mailing list archive) |
---|---|
State | Accepted |
Commit | 4c907bcd9dcd233da6707059d777ab389dcbd964 |
Headers | show |
Series | ASoC: max9759: fix underflow in speaker_gain_control_put() | expand |
On Wed, 19 Jan 2022 15:31:01 +0300, Dan Carpenter wrote: > Check for negative values of "priv->gain" to prevent an out of bounds > access. The concern is that these might come from the user via: > -> snd_ctl_elem_write_user() > -> snd_ctl_elem_write() > -> kctl->put() > > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus Thanks! [1/1] ASoC: max9759: fix underflow in speaker_gain_control_put() commit: 4c907bcd9dcd233da6707059d777ab389dcbd964 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/sound/soc/codecs/max9759.c b/sound/soc/codecs/max9759.c index d75fd61b9032..bc57d7687f16 100644 --- a/sound/soc/codecs/max9759.c +++ b/sound/soc/codecs/max9759.c @@ -64,7 +64,8 @@ static int speaker_gain_control_put(struct snd_kcontrol *kcontrol, struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); struct max9759 *priv = snd_soc_component_get_drvdata(c); - if (ucontrol->value.integer.value[0] > 3) + if (ucontrol->value.integer.value[0] < 0 || + ucontrol->value.integer.value[0] > 3) return -EINVAL; priv->gain = ucontrol->value.integer.value[0];
Check for negative values of "priv->gain" to prevent an out of bounds access. The concern is that these might come from the user via: -> snd_ctl_elem_write_user() -> snd_ctl_elem_write() -> kctl->put() Fixes: fa8d915172b8 ("ASoC: max9759: Add Amplifier Driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- From static analysis. Not tested. This patch is obviously harmless but I sometimes get confused about these sound get()/put() functions. I have some code in Smatch which is supposed to manually suppress warnings from snd_ctl_elem_write() but it was four years old and has bitrotted so that's how I got this warning. So I remember these as being false positives where Smatch gets confused but when I searched my mailbox I just see similar patches which were applied. sound/soc/codecs/max9759.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)