aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-11-15 10:17:24 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:25 -0500
commit3b892467786410f26dffc2c7bccd3ea445604037 (patch)
tree4a70f86b1545e9be95d987fc248cac3cebbbd9a8 /sound/drivers
parent498ade1a133dffd0f3ee90952737045d56e6689a (diff)
[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/drivers')
-rw-r--r--sound/drivers/mts64.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index dcc90f995294..68070cccc6be 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -461,13 +461,14 @@ static int snd_mts64_ctl_smpte_switch_put(struct snd_kcontrol* kctl,
461{ 461{
462 struct mts64 *mts = snd_kcontrol_chip(kctl); 462 struct mts64 *mts = snd_kcontrol_chip(kctl);
463 int changed = 0; 463 int changed = 0;
464 int val = !!uctl->value.integer.value[0];
464 465
465 spin_lock_irq(&mts->lock); 466 spin_lock_irq(&mts->lock);
466 if (mts->smpte_switch == uctl->value.integer.value[0]) 467 if (mts->smpte_switch == val)
467 goto __out; 468 goto __out;
468 469
469 changed = 1; 470 changed = 1;
470 mts->smpte_switch = uctl->value.integer.value[0]; 471 mts->smpte_switch = val;
471 if (mts->smpte_switch) { 472 if (mts->smpte_switch) {
472 mts64_smpte_start(mts->pardev->port, 473 mts64_smpte_start(mts->pardev->port,
473 mts->time[0], mts->time[1], 474 mts->time[0], mts->time[1],
@@ -541,12 +542,13 @@ static int snd_mts64_ctl_smpte_time_put(struct snd_kcontrol *kctl,
541{ 542{
542 struct mts64 *mts = snd_kcontrol_chip(kctl); 543 struct mts64 *mts = snd_kcontrol_chip(kctl);
543 int idx = kctl->private_value; 544 int idx = kctl->private_value;
545 unsigned int time = uctl->value.integer.value[0] % 60;
544 int changed = 0; 546 int changed = 0;
545 547
546 spin_lock_irq(&mts->lock); 548 spin_lock_irq(&mts->lock);
547 if (mts->time[idx] != uctl->value.integer.value[0]) { 549 if (mts->time[idx] != time) {
548 changed = 1; 550 changed = 1;
549 mts->time[idx] = uctl->value.integer.value[0]; 551 mts->time[idx] = time;
550 } 552 }
551 spin_unlock_irq(&mts->lock); 553 spin_unlock_irq(&mts->lock);
552 554
@@ -636,6 +638,8 @@ static int snd_mts64_ctl_smpte_fps_put(struct snd_kcontrol *kctl,
636 struct mts64 *mts = snd_kcontrol_chip(kctl); 638 struct mts64 *mts = snd_kcontrol_chip(kctl);
637 int changed = 0; 639 int changed = 0;
638 640
641 if (uctl->value.enumerated.item[0] >= 5)
642 return -EINVAL;
639 spin_lock_irq(&mts->lock); 643 spin_lock_irq(&mts->lock);
640 if (mts->fps != uctl->value.enumerated.item[0]) { 644 if (mts->fps != uctl->value.enumerated.item[0]) {
641 changed = 1; 645 changed = 1;