diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 10:14:12 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:25 -0500 |
commit | d4079ac49a08e36d6839a9ceb26aec8c24c9ed82 (patch) | |
tree | 91ebc493375fd4e7fa84c3a6ab67a885121b1c81 /sound/ppc/awacs.c | |
parent | d05ab185b770de96399766be6bcb5769ab99bc09 (diff) |
[ALSA] powermac - Check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly in snd-powermac
driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/ppc/awacs.c')
-rw-r--r-- | sound/ppc/awacs.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 05dabe454658..b15bfb6f7011 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c | |||
@@ -175,10 +175,12 @@ static int snd_pmac_awacs_put_volume(struct snd_kcontrol *kcontrol, | |||
175 | int inverted = (kcontrol->private_value >> 16) & 1; | 175 | int inverted = (kcontrol->private_value >> 16) & 1; |
176 | int val, oldval; | 176 | int val, oldval; |
177 | unsigned long flags; | 177 | unsigned long flags; |
178 | int vol[2]; | 178 | unsigned int vol[2]; |
179 | 179 | ||
180 | vol[0] = ucontrol->value.integer.value[0]; | 180 | vol[0] = ucontrol->value.integer.value[0]; |
181 | vol[1] = ucontrol->value.integer.value[1]; | 181 | vol[1] = ucontrol->value.integer.value[1]; |
182 | if (vol[0] > 0x0f || vol[1] > 0x0f) | ||
183 | return -EINVAL; | ||
182 | if (inverted) { | 184 | if (inverted) { |
183 | vol[0] = 0x0f - vol[0]; | 185 | vol[0] = 0x0f - vol[0]; |
184 | vol[1] = 0x0f - vol[1]; | 186 | vol[1] = 0x0f - vol[1]; |
@@ -421,10 +423,14 @@ static int snd_pmac_awacs_put_tone_amp(struct snd_kcontrol *kcontrol, | |||
421 | struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); | 423 | struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
422 | int index = kcontrol->private_value; | 424 | int index = kcontrol->private_value; |
423 | struct awacs_amp *amp = chip->mixer_data; | 425 | struct awacs_amp *amp = chip->mixer_data; |
426 | unsigned int val; | ||
424 | snd_assert(amp, return -EINVAL); | 427 | snd_assert(amp, return -EINVAL); |
425 | snd_assert(index >= 0 && index <= 1, return -EINVAL); | 428 | snd_assert(index >= 0 && index <= 1, return -EINVAL); |
426 | if (ucontrol->value.integer.value[0] != amp->amp_tone[index]) { | 429 | val = ucontrol->value.integer.value[0]; |
427 | amp->amp_tone[index] = ucontrol->value.integer.value[0]; | 430 | if (val > 14) |
431 | return -EINVAL; | ||
432 | if (val != amp->amp_tone[index]) { | ||
433 | amp->amp_tone[index] = val; | ||
428 | awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); | 434 | awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); |
429 | return 1; | 435 | return 1; |
430 | } | 436 | } |
@@ -456,9 +462,13 @@ static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol, | |||
456 | { | 462 | { |
457 | struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); | 463 | struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); |
458 | struct awacs_amp *amp = chip->mixer_data; | 464 | struct awacs_amp *amp = chip->mixer_data; |
465 | unsigned int val; | ||
459 | snd_assert(amp, return -EINVAL); | 466 | snd_assert(amp, return -EINVAL); |
460 | if (ucontrol->value.integer.value[0] != amp->amp_master) { | 467 | val = ucontrol->value.integer.value[0]; |
461 | amp->amp_master = ucontrol->value.integer.value[0]; | 468 | if (val > 99) |
469 | return -EINVAL; | ||
470 | if (val != amp->amp_master) { | ||
471 | amp->amp_master = val; | ||
462 | awacs_amp_set_master(amp, amp->amp_master); | 472 | awacs_amp_set_master(amp, amp->amp_master); |
463 | return 1; | 473 | return 1; |
464 | } | 474 | } |