summaryrefslogtreecommitdiffstats
path: root/sound/pci/echoaudio
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2015-03-23 05:41:31 -0400
committerTakashi Iwai <tiwai@suse.de>2015-03-23 09:00:28 -0400
commit77008b70fe0a9ffe354580d9dfda329cdde7f20b (patch)
treeabf0888bcd55c82a26218df1596cf674e51e4515 /sound/pci/echoaudio
parent034f90b393a3d5c99654f048c4b22b3d05e3a345 (diff)
ALSA: echoaudio: read past end of array
We need to cap "ucontrol->id.index / num_busses_in(chip)" so the we don't read beyond the end of the array. I also adding a check on "in" and changing the type in snd_echo_mixer_put() from short to unsigned int. Those changes are done for symmetry and are cosmetic. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/echoaudio')
-rw-r--r--sound/pci/echoaudio/echoaudio.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index a962de03ebb6..862db9a0b041 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -1283,12 +1283,14 @@ static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol,
1283static int snd_echo_mixer_get(struct snd_kcontrol *kcontrol, 1283static int snd_echo_mixer_get(struct snd_kcontrol *kcontrol,
1284 struct snd_ctl_elem_value *ucontrol) 1284 struct snd_ctl_elem_value *ucontrol)
1285{ 1285{
1286 struct echoaudio *chip; 1286 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1287 unsigned int out = ucontrol->id.index / num_busses_in(chip);
1288 unsigned int in = ucontrol->id.index % num_busses_in(chip);
1287 1289
1288 chip = snd_kcontrol_chip(kcontrol); 1290 if (out >= ECHO_MAXAUDIOOUTPUTS || in >= ECHO_MAXAUDIOINPUTS)
1289 ucontrol->value.integer.value[0] = 1291 return -EINVAL;
1290 chip->monitor_gain[ucontrol->id.index / num_busses_in(chip)] 1292
1291 [ucontrol->id.index % num_busses_in(chip)]; 1293 ucontrol->value.integer.value[0] = chip->monitor_gain[out][in];
1292 return 0; 1294 return 0;
1293} 1295}
1294 1296
@@ -1297,12 +1299,14 @@ static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
1297{ 1299{
1298 struct echoaudio *chip; 1300 struct echoaudio *chip;
1299 int changed, gain; 1301 int changed, gain;
1300 short out, in; 1302 unsigned int out, in;
1301 1303
1302 changed = 0; 1304 changed = 0;
1303 chip = snd_kcontrol_chip(kcontrol); 1305 chip = snd_kcontrol_chip(kcontrol);
1304 out = ucontrol->id.index / num_busses_in(chip); 1306 out = ucontrol->id.index / num_busses_in(chip);
1305 in = ucontrol->id.index % num_busses_in(chip); 1307 in = ucontrol->id.index % num_busses_in(chip);
1308 if (out >= ECHO_MAXAUDIOOUTPUTS || in >= ECHO_MAXAUDIOINPUTS)
1309 return -EINVAL;
1306 gain = ucontrol->value.integer.value[0]; 1310 gain = ucontrol->value.integer.value[0];
1307 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT) 1311 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
1308 return -EINVAL; 1312 return -EINVAL;