[ALSA] emu10k1: Add mixer controls parameter checking.

2008-01-31 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=83a28a09c8d02d29c17e903ca713d9b8f4159ad4
Commit: 83a28a09c8d02d29c17e903ca713d9b8f4159ad4
Parent: 40c1d30871346c7428d3876fc4c6b593b1b875f2
Author: James Courtier-Dutton <[EMAIL PROTECTED]>
AuthorDate: Mon Nov 12 14:55:19 2007 +
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Thu Jan 31 17:29:22 2008 +0100

[ALSA] emu10k1: Add mixer controls parameter checking.


Signed-off-by: James Courtier-Dutton <[EMAIL PROTECTED]>
Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/pci/emu10k1/emumixer.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index ccacd7b..4b85a6b 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -1089,6 +1089,7 @@ static int snd_emu10k1_send_volume_put(struct 
snd_kcontrol *kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
struct snd_emu10k1_pcm_mixer *mix =
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
int change = 0, idx, val;
@@ -1141,6 +1142,7 @@ static int snd_emu10k1_attn_get(struct snd_kcontrol 
*kcontrol,
 struct snd_ctl_elem_value *ucontrol)
 {
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
struct snd_emu10k1_pcm_mixer *mix =
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
unsigned long flags;
@@ -1158,6 +1160,7 @@ static int snd_emu10k1_attn_put(struct snd_kcontrol 
*kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
struct snd_emu10k1_pcm_mixer *mix =
&emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
int change = 0, idx, val;
@@ -1210,6 +1213,7 @@ static int snd_emu10k1_efx_send_routing_get(struct 
snd_kcontrol *kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
struct snd_emu10k1_pcm_mixer *mix =
&emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, 
&ucontrol->id)];
int idx;
@@ -1229,6 +1233,7 @@ static int snd_emu10k1_efx_send_routing_put(struct 
snd_kcontrol *kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
int change = 0, idx, val;
@@ -1280,6 +1285,7 @@ static int snd_emu10k1_efx_send_volume_get(struct 
snd_kcontrol *kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
struct snd_emu10k1_pcm_mixer *mix =
&emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, 
&ucontrol->id)];
int idx;
@@ -1297,6 +1303,7 @@ static int snd_emu10k1_efx_send_volume_put(struct 
snd_kcontrol *kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
int change = 0, idx, val;
@@ -1345,6 +1352,7 @@ static int snd_emu10k1_efx_attn_get(struct snd_kcontrol 
*kcontrol,
 struct snd_ctl_elem_value *ucontrol)
 {
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
struct snd_emu10k1_pcm_mixer *mix =
&emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, 
&ucontrol->id)];
unsigned long flags;
@@ -1360,6 +1368,7 @@ static int snd_emu10k1_efx_attn_put(struct snd_kcontrol 
*kcontrol,
 {
unsigned long flags;
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
+   /* FIXME: Check limits */
int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
int change = 0, val;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ALSA] emu10k1: Add mixer controls parameter checking.

2007-11-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=74415a36767d99d3adf31b4a62e4e50725e6b66a
Commit: 74415a36767d99d3adf31b4a62e4e50725e6b66a
Parent: 4df20535ec52fb7eba604eb1ba77148f92ab8edd
Author: James Courtier-Dutton <[EMAIL PROTECTED]>
AuthorDate: Mon Nov 12 14:55:19 2007 +
Committer:  Mercurial server <[EMAIL PROTECTED]>
CommitDate: Tue Nov 20 20:03:32 2007 +0100

[ALSA] emu10k1: Add mixer controls parameter checking.


Signed-off-by: James Courtier-Dutton <[EMAIL PROTECTED]>
Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/pci/emu10k1/emumixer.c |   60 +++--
 1 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 54a2034..88eab4a 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -58,6 +58,9 @@ static int snd_emu10k1_spdif_get(struct snd_kcontrol 
*kcontrol,
unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
unsigned long flags;
 
+   /* Limit: emu->spdif_bits */
+   if (idx >= 3)
+   return -EINVAL;
spin_lock_irqsave(&emu->reg_lock, flags);
ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff;
ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff;
@@ -272,9 +275,12 @@ static int snd_emu1010_output_source_get(struct 
snd_kcontrol *kcontrol,
  struct snd_ctl_elem_value *ucontrol)
 {
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
-   int channel;
+   unsigned int channel;
 
channel = (kcontrol->private_value) & 0xff;
+   /* Limit: emu1010_output_dst, emu->emu1010.output_source */
+   if (channel >= 24)
+   return -EINVAL;
ucontrol->value.enumerated.item[0] = 
emu->emu1010.output_source[channel];
return 0;
 }
@@ -285,9 +291,12 @@ static int snd_emu1010_output_source_put(struct 
snd_kcontrol *kcontrol,
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
int change = 0;
unsigned int val;
-   int channel;
+   unsigned int channel;
 
channel = (kcontrol->private_value) & 0xff;
+   /* Limit: emu1010_output_dst, emu->emu1010.output_source */
+   if (channel >= 24)
+   return -EINVAL;
if (emu->emu1010.output_source[channel] != 
ucontrol->value.enumerated.item[0]) {
val = emu->emu1010.output_source[channel] = 
ucontrol->value.enumerated.item[0];
change = 1;
@@ -301,9 +310,12 @@ static int snd_emu1010_input_source_get(struct 
snd_kcontrol *kcontrol,
  struct snd_ctl_elem_value *ucontrol)
 {
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
-   int channel;
+   unsigned int channel;
 
channel = (kcontrol->private_value) & 0xff;
+   /* Limit: emu1010_input_dst, emu->emu1010.input_source */
+   if (channel >= 22)
+   return -EINVAL;
ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel];
return 0;
 }
@@ -314,9 +326,12 @@ static int snd_emu1010_input_source_put(struct 
snd_kcontrol *kcontrol,
struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
int change = 0;
unsigned int val;
-   int channel;
+   unsigned int channel;
 
channel = (kcontrol->private_value) & 0xff;
+   /* Limit: emu1010_input_dst, emu->emu1010.input_source */
+   if (channel >= 22)
+   return -EINVAL;
if (emu->emu1010.input_source[channel] != 
ucontrol->value.enumerated.item[0]) {
val = emu->emu1010.input_source[channel] = 
ucontrol->value.enumerated.item[0];
change = 1;
@@ -533,6 +548,9 @@ static int snd_emu1010_internal_clock_put(struct 
snd_kcontrol *kcontrol,
int change = 0;
 
val = ucontrol->value.enumerated.item[0] ;
+   /* Limit: uinfo->value.enumerated.items = 4; */
+   if (val >= 4)
+   return -EINVAL;
change = (emu->emu1010.internal_clock != val);
if (change) {
emu->emu1010.internal_clock = val;
@@ -669,7 +687,11 @@ static int snd_audigy_i2c_capture_source_put(struct 
snd_kcontrol *kcontrol,
 * update the capture volume from the cached value
 * for the particular source.
 */
-   source_id = ucontrol->value.enumerated.item[0]; /* Use 2 and 3 */
+   source_id = ucontrol->value.enumerated.item[0];
+   /* Limit: uinfo->value.enumerated.items = 2; */
+   /*emu->i2c_capture_volume */
+   if (source_id >= 2)
+   return -EINVAL;
change = (emu->i2c_capture_source !