Skip to content

Commit 4c907bc

Browse files
Dan Carpenterbroonie
authored andcommitted
ASoC: max9759: fix underflow in speaker_gain_control_put()
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 <[email protected]> Link: https://lore.kernel.org/r/20220119123101.GA9509@kili Signed-off-by: Mark Brown <[email protected]>
1 parent f7a6021 commit 4c907bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sound/soc/codecs/max9759.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static int speaker_gain_control_put(struct snd_kcontrol *kcontrol,
6464
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
6565
struct max9759 *priv = snd_soc_component_get_drvdata(c);
6666

67-
if (ucontrol->value.integer.value[0] > 3)
67+
if (ucontrol->value.integer.value[0] < 0 ||
68+
ucontrol->value.integer.value[0] > 3)
6869
return -EINVAL;
6970

7071
priv->gain = ucontrol->value.integer.value[0];

0 commit comments

Comments
 (0)