diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 16:14:12 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 17:29:25 +0100 |
commit | d4079ac49a08e36d6839a9ceb26aec8c24c9ed82 (patch) | |
tree | 91ebc493375fd4e7fa84c3a6ab67a885121b1c81 /sound/ppc/burgundy.c | |
parent | d05ab185b770de96399766be6bcb5769ab99bc09 (diff) | |
download | kernel_samsung_espresso10-d4079ac49a08e36d6839a9ceb26aec8c24c9ed82.zip kernel_samsung_espresso10-d4079ac49a08e36d6839a9ceb26aec8c24c9ed82.tar.gz kernel_samsung_espresso10-d4079ac49a08e36d6839a9ceb26aec8c24c9ed82.tar.bz2 |
[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/burgundy.c')
-rw-r--r-- | sound/ppc/burgundy.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index e02263f..fec74e8 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c @@ -136,6 +136,9 @@ snd_pmac_burgundy_write_volume(struct snd_pmac *chip, unsigned int address, { int hardvolume, lvolume, rvolume; + if (volume[0] < 0 || volume[0] > 100 || + volume[1] < 0 || volume[1] > 100) + return; /* -EINVAL */ lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0; rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0; @@ -301,14 +304,14 @@ static int snd_pmac_burgundy_put_volume_out(struct snd_kcontrol *kcontrol, struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); int stereo = (kcontrol->private_value >> 24) & 1; - int oval, val; + unsigned int oval, val; oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff; - val = ucontrol->value.integer.value[0]; + val = ucontrol->value.integer.value[0] & 15; if (stereo) - val |= ucontrol->value.integer.value[1] << 4; + val |= (ucontrol->value.integer.value[1] & 15) << 4; else - val |= ucontrol->value.integer.value[0] << 4; + val |= val << 4; val = ~val & 0xff; snd_pmac_burgundy_wcb(chip, addr, val); return val != oval; |