diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-11-15 09:58:13 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:24 -0500 |
commit | 4e98d6a7ce934b19bffb309f2522b22384355fef (patch) | |
tree | 8613aee414a855314663de2575f2bee284c8430c /sound/pci/ac97 | |
parent | ab2dac2bdcf562dd616bd1fadddf5078ae7c3d83 (diff) |
[ALSA] pci - check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly in the rest of
PCI drivers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/ac97')
-rw-r--r-- | sound/pci/ac97/ac97_patch.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 98c8b727b62b..50c637e55ffa 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -133,6 +133,14 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
133 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); | 133 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); |
134 | unsigned char mode = ucontrol->value.enumerated.item[0]; | 134 | unsigned char mode = ucontrol->value.enumerated.item[0]; |
135 | 135 | ||
136 | if (kcontrol->private_value) { | ||
137 | if (mode >= 2) | ||
138 | return -EINVAL; | ||
139 | } else { | ||
140 | if (mode >= 3) | ||
141 | return -EINVAL; | ||
142 | } | ||
143 | |||
136 | if (mode != ac97->channel_mode) { | 144 | if (mode != ac97->channel_mode) { |
137 | ac97->channel_mode = mode; | 145 | ac97->channel_mode = mode; |
138 | if (ac97->build_ops->update_jacks) | 146 | if (ac97->build_ops->update_jacks) |
@@ -2142,8 +2150,7 @@ static int snd_ac97_ad1985_vrefout_put(struct snd_kcontrol *kcontrol, | |||
2142 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); | 2150 | struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); |
2143 | unsigned short val; | 2151 | unsigned short val; |
2144 | 2152 | ||
2145 | if (ucontrol->value.enumerated.item[0] > 3 | 2153 | if (ucontrol->value.enumerated.item[0] > 3) |
2146 | || ucontrol->value.enumerated.item[0] < 0) | ||
2147 | return -EINVAL; | 2154 | return -EINVAL; |
2148 | val = ctrl2reg[ucontrol->value.enumerated.item[0]] | 2155 | val = ctrl2reg[ucontrol->value.enumerated.item[0]] |
2149 | << AC97_AD198X_VREF_SHIFT; | 2156 | << AC97_AD198X_VREF_SHIFT; |