Skip to content

Commit

Permalink
ASoC: max9759: fix underflow in speaker_gain_control_put()
Browse files Browse the repository at this point in the history
commit 4c907bc upstream.

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: fa8d915 ("ASoC: max9759: Add Amplifier Driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220119123101.GA9509@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Feb 8, 2022
1 parent 02f4597 commit 5a45448
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/soc/codecs/max9759.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 5a45448

Please sign in to comment.