diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 10:16:32 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:25 -0500 |
commit | 498ade1a133dffd0f3ee90952737045d56e6689a (patch) | |
tree | 2ab70ccf64f0aa1d615d026a56705a77ca0eb305 /sound/aoa/codecs/snd-aoa-codec-tas.c | |
parent | 02ff1324930675599694bb1285afc4341f98a7a1 (diff) |
[ALSA] aoa - Check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly in aoa drivers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/aoa/codecs/snd-aoa-codec-tas.c')
-rw-r--r-- | sound/aoa/codecs/snd-aoa-codec-tas.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.c b/sound/aoa/codecs/snd-aoa-codec-tas.c index 70c341684794..7a16a3331f7e 100644 --- a/sound/aoa/codecs/snd-aoa-codec-tas.c +++ b/sound/aoa/codecs/snd-aoa-codec-tas.c | |||
@@ -248,6 +248,13 @@ static int tas_snd_vol_put(struct snd_kcontrol *kcontrol, | |||
248 | { | 248 | { |
249 | struct tas *tas = snd_kcontrol_chip(kcontrol); | 249 | struct tas *tas = snd_kcontrol_chip(kcontrol); |
250 | 250 | ||
251 | if (ucontrol->value.integer.value[0] < 0 || | ||
252 | ucontrol->value.integer.value[0] > 177) | ||
253 | return -EINVAL; | ||
254 | if (ucontrol->value.integer.value[1] < 0 || | ||
255 | ucontrol->value.integer.value[1] > 177) | ||
256 | return -EINVAL; | ||
257 | |||
251 | mutex_lock(&tas->mtx); | 258 | mutex_lock(&tas->mtx); |
252 | if (tas->cached_volume_l == ucontrol->value.integer.value[0] | 259 | if (tas->cached_volume_l == ucontrol->value.integer.value[0] |
253 | && tas->cached_volume_r == ucontrol->value.integer.value[1]) { | 260 | && tas->cached_volume_r == ucontrol->value.integer.value[1]) { |
@@ -401,6 +408,10 @@ static int tas_snd_drc_range_put(struct snd_kcontrol *kcontrol, | |||
401 | { | 408 | { |
402 | struct tas *tas = snd_kcontrol_chip(kcontrol); | 409 | struct tas *tas = snd_kcontrol_chip(kcontrol); |
403 | 410 | ||
411 | if (ucontrol->value.integer.value[0] < 0 || | ||
412 | ucontrol->value.integer.value[0] > TAS3004_DRC_MAX) | ||
413 | return -EINVAL; | ||
414 | |||
404 | mutex_lock(&tas->mtx); | 415 | mutex_lock(&tas->mtx); |
405 | if (tas->drc_range == ucontrol->value.integer.value[0]) { | 416 | if (tas->drc_range == ucontrol->value.integer.value[0]) { |
406 | mutex_unlock(&tas->mtx); | 417 | mutex_unlock(&tas->mtx); |
@@ -447,7 +458,7 @@ static int tas_snd_drc_switch_put(struct snd_kcontrol *kcontrol, | |||
447 | return 0; | 458 | return 0; |
448 | } | 459 | } |
449 | 460 | ||
450 | tas->drc_enabled = ucontrol->value.integer.value[0]; | 461 | tas->drc_enabled = !!ucontrol->value.integer.value[0]; |
451 | if (tas->hw_enabled) | 462 | if (tas->hw_enabled) |
452 | tas3004_set_drc(tas); | 463 | tas3004_set_drc(tas); |
453 | mutex_unlock(&tas->mtx); | 464 | mutex_unlock(&tas->mtx); |
@@ -494,6 +505,8 @@ static int tas_snd_capture_source_put(struct snd_kcontrol *kcontrol, | |||
494 | struct tas *tas = snd_kcontrol_chip(kcontrol); | 505 | struct tas *tas = snd_kcontrol_chip(kcontrol); |
495 | int oldacr; | 506 | int oldacr; |
496 | 507 | ||
508 | if (ucontrol->value.enumerated.item[0] > 1) | ||
509 | return -EINVAL; | ||
497 | mutex_lock(&tas->mtx); | 510 | mutex_lock(&tas->mtx); |
498 | oldacr = tas->acr; | 511 | oldacr = tas->acr; |
499 | 512 | ||
@@ -562,6 +575,9 @@ static int tas_snd_treble_put(struct snd_kcontrol *kcontrol, | |||
562 | { | 575 | { |
563 | struct tas *tas = snd_kcontrol_chip(kcontrol); | 576 | struct tas *tas = snd_kcontrol_chip(kcontrol); |
564 | 577 | ||
578 | if (ucontrol->value.integer.value[0] < TAS3004_TREBLE_MIN || | ||
579 | ucontrol->value.integer.value[0] > TAS3004_TREBLE_MAX) | ||
580 | return -EINVAL; | ||
565 | mutex_lock(&tas->mtx); | 581 | mutex_lock(&tas->mtx); |
566 | if (tas->treble == ucontrol->value.integer.value[0]) { | 582 | if (tas->treble == ucontrol->value.integer.value[0]) { |
567 | mutex_unlock(&tas->mtx); | 583 | mutex_unlock(&tas->mtx); |
@@ -610,6 +626,9 @@ static int tas_snd_bass_put(struct snd_kcontrol *kcontrol, | |||
610 | { | 626 | { |
611 | struct tas *tas = snd_kcontrol_chip(kcontrol); | 627 | struct tas *tas = snd_kcontrol_chip(kcontrol); |
612 | 628 | ||
629 | if (ucontrol->value.integer.value[0] < TAS3004_BASS_MIN || | ||
630 | ucontrol->value.integer.value[0] > TAS3004_BASS_MAX) | ||
631 | return -EINVAL; | ||
613 | mutex_lock(&tas->mtx); | 632 | mutex_lock(&tas->mtx); |
614 | if (tas->bass == ucontrol->value.integer.value[0]) { | 633 | if (tas->bass == ucontrol->value.integer.value[0]) { |
615 | mutex_unlock(&tas->mtx); | 634 | mutex_unlock(&tas->mtx); |