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-onyx.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-onyx.c')
-rw-r--r-- | sound/aoa/codecs/snd-aoa-codec-onyx.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c b/sound/aoa/codecs/snd-aoa-codec-onyx.c index 71e3f9360658..6a3837d480e5 100644 --- a/sound/aoa/codecs/snd-aoa-codec-onyx.c +++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c | |||
@@ -138,6 +138,13 @@ static int onyx_snd_vol_put(struct snd_kcontrol *kcontrol, | |||
138 | struct onyx *onyx = snd_kcontrol_chip(kcontrol); | 138 | struct onyx *onyx = snd_kcontrol_chip(kcontrol); |
139 | s8 l, r; | 139 | s8 l, r; |
140 | 140 | ||
141 | if (ucontrol->value.integer.value[0] < -128 + VOLUME_RANGE_SHIFT || | ||
142 | ucontrol->value.integer.value[0] > -1 + VOLUME_RANGE_SHIFT) | ||
143 | return -EINVAL; | ||
144 | if (ucontrol->value.integer.value[1] < -128 + VOLUME_RANGE_SHIFT || | ||
145 | ucontrol->value.integer.value[1] > -1 + VOLUME_RANGE_SHIFT) | ||
146 | return -EINVAL; | ||
147 | |||
141 | mutex_lock(&onyx->mutex); | 148 | mutex_lock(&onyx->mutex); |
142 | onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l); | 149 | onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l); |
143 | onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r); | 150 | onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r); |
@@ -206,6 +213,9 @@ static int onyx_snd_inputgain_put(struct snd_kcontrol *kcontrol, | |||
206 | struct onyx *onyx = snd_kcontrol_chip(kcontrol); | 213 | struct onyx *onyx = snd_kcontrol_chip(kcontrol); |
207 | u8 v, n; | 214 | u8 v, n; |
208 | 215 | ||
216 | if (ucontrol->value.integer.value[0] < 3 + INPUTGAIN_RANGE_SHIFT || | ||
217 | ucontrol->value.integer.value[0] > 28 + INPUTGAIN_RANGE_SHIFT) | ||
218 | return -EINVAL; | ||
209 | mutex_lock(&onyx->mutex); | 219 | mutex_lock(&onyx->mutex); |
210 | onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v); | 220 | onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v); |
211 | n = v; | 221 | n = v; |
@@ -272,6 +282,8 @@ static void onyx_set_capture_source(struct onyx *onyx, int mic) | |||
272 | static int onyx_snd_capture_source_put(struct snd_kcontrol *kcontrol, | 282 | static int onyx_snd_capture_source_put(struct snd_kcontrol *kcontrol, |
273 | struct snd_ctl_elem_value *ucontrol) | 283 | struct snd_ctl_elem_value *ucontrol) |
274 | { | 284 | { |
285 | if (ucontrol->value.enumerated.item[0] > 1) | ||
286 | return -EINVAL; | ||
275 | onyx_set_capture_source(snd_kcontrol_chip(kcontrol), | 287 | onyx_set_capture_source(snd_kcontrol_chip(kcontrol), |
276 | ucontrol->value.enumerated.item[0]); | 288 | ucontrol->value.enumerated.item[0]); |
277 | return 1; | 289 | return 1; |