summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorGeoffrey D. Bennett <g@b4.vu>2023-12-19 20:37:52 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-26 02:35:39 +0300
commit03035872e17897ba89866940bbc9cefca601e572 (patch)
tree56e5e01e0dd3838fc5417ba6b42d9722c8299e09 /sound
parent821fbaeaaae23d483d3df799fe91ec8045973ec3 (diff)
downloadlinux-03035872e17897ba89866940bbc9cefca601e572.tar.xz
ALSA: scarlett2: Add clamp() in scarlett2_mixer_ctl_put()
[ Upstream commit 04f8f053252b86c7583895c962d66747ecdc61b7 ] Ensure the value passed to scarlett2_mixer_ctl_put() is between 0 and SCARLETT2_MIXER_MAX_VALUE so we don't attempt to access outside scarlett2_mixer_values[]. Signed-off-by: Geoffrey D. Bennett <g@b4.vu> Fixes: 9e4d5c1be21f ("ALSA: usb-audio: Scarlett Gen 2 mixer interface") Link: https://lore.kernel.org/r/3b19fb3da641b587749b85fe1daa1b4e696c0c1b.1703001053.git.g@b4.vu Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/mixer_scarlett_gen2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
index 087e120d7103..c04cff722541 100644
--- a/sound/usb/mixer_scarlett_gen2.c
+++ b/sound/usb/mixer_scarlett_gen2.c
@@ -3361,7 +3361,8 @@ static int scarlett2_mixer_ctl_put(struct snd_kcontrol *kctl,
mutex_lock(&private->data_mutex);
oval = private->mix[index];
- val = ucontrol->value.integer.value[0];
+ val = clamp(ucontrol->value.integer.value[0],
+ 0L, (long)SCARLETT2_MIXER_MAX_VALUE);
num_mixer_in = port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_OUT];
mix_num = index / num_mixer_in;