aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc/burgundy.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-11-15 10:14:12 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:25 -0500
commitd4079ac49a08e36d6839a9ceb26aec8c24c9ed82 (patch)
tree91ebc493375fd4e7fa84c3a6ab67a885121b1c81 /sound/ppc/burgundy.c
parentd05ab185b770de96399766be6bcb5769ab99bc09 (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/burgundy.c')
-rw-r--r--sound/ppc/burgundy.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c
index e02263fe44dc..fec74e829743 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,
136{ 136{
137 int hardvolume, lvolume, rvolume; 137 int hardvolume, lvolume, rvolume;
138 138
139 if (volume[0] < 0 || volume[0] > 100 ||
140 volume[1] < 0 || volume[1] > 100)
141 return; /* -EINVAL */
139 lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0; 142 lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0;
140 rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0; 143 rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0;
141 144
@@ -301,14 +304,14 @@ static int snd_pmac_burgundy_put_volume_out(struct snd_kcontrol *kcontrol,
301 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 304 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
302 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); 305 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
303 int stereo = (kcontrol->private_value >> 24) & 1; 306 int stereo = (kcontrol->private_value >> 24) & 1;
304 int oval, val; 307 unsigned int oval, val;
305 308
306 oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff; 309 oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff;
307 val = ucontrol->value.integer.value[0]; 310 val = ucontrol->value.integer.value[0] & 15;
308 if (stereo) 311 if (stereo)
309 val |= ucontrol->value.integer.value[1] << 4; 312 val |= (ucontrol->value.integer.value[1] & 15) << 4;
310 else 313 else
311 val |= ucontrol->value.integer.value[0] << 4; 314 val |= val << 4;
312 val = ~val & 0xff; 315 val = ~val & 0xff;
313 snd_pmac_burgundy_wcb(chip, addr, val); 316 snd_pmac_burgundy_wcb(chip, addr, val);
314 return val != oval; 317 return val != oval;