diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 16:17:24 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 17:29:25 +0100 |
commit | 3b892467786410f26dffc2c7bccd3ea445604037 (patch) | |
tree | 4a70f86b1545e9be95d987fc248cac3cebbbd9a8 /sound/sparc | |
parent | 498ade1a133dffd0f3ee90952737045d56e6689a (diff) | |
download | linux-3b892467786410f26dffc2c7bccd3ea445604037.tar.gz linux-3b892467786410f26dffc2c7bccd3ea445604037.tar.bz2 linux-3b892467786410f26dffc2c7bccd3ea445604037.zip |
[ALSA] Check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly (in the rest drivers).
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/sparc')
-rw-r--r-- | sound/sparc/amd7930.c | 2 | ||||
-rw-r--r-- | sound/sparc/dbri.c | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 07962a35f241..b1d431587158 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -859,7 +859,7 @@ static int snd_amd7930_put_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem spin_lock_irqsave(&amd->lock, flags); if (*swval != ucontrol->value.integer.value[0]) { - *swval = ucontrol->value.integer.value[0]; + *swval = ucontrol->value.integer.value[0] & 0xff; __amd7930_update_map(amd); change = 1; } else diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 376b98691c96..af1bf4bf9459 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2279,9 +2279,20 @@ static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol, struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); struct dbri_streaminfo *info = &dbri->stream_info[kcontrol->private_value]; + unsigned int vol[2]; int changed = 0; - if (info->left_gain != ucontrol->value.integer.value[0]) { + vol[0] = ucontrol->value.integer.value[0]; + vol[1] = ucontrol->value.integer.value[1]; + if (kcontrol->private_value == DBRI_PLAY) { + if (vol[0] > DBRI_MAX_VOLUME || vol[1] > DBRI_MAX_VOLUME) + return -EINVAL; + } else { + if (vol[0] > DBRI_MAX_GAIN || vol[1] > DBRI_MAX_GAIN) + return -EINVAL; + } + + if (info->left_gain != info->left_gain = ucontrol->value.integer.value[0]; changed = 1; } |