Commit cca80b97 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Mauro Carvalho Chehab

V4L/DVB: cx88-alsa: prevent out-of-range volume setting

Ensure that volume values are always in the allowed range.  Otherwise,
it would be possible to set other bits in the AUD_VOL_CTL register or to
get a wrong sign in the AUD_BAL_CTL register.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 071193ff
...@@ -583,16 +583,18 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, ...@@ -583,16 +583,18 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
{ {
snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
struct cx88_core *core=chip->core; struct cx88_core *core=chip->core;
int v, b; int left, right, v, b;
int changed = 0; int changed = 0;
u32 old; u32 old;
b = value->value.integer.value[1] - value->value.integer.value[0]; left = value->value.integer.value[0] & 0x3f;
right = value->value.integer.value[1] & 0x3f;
b = right - left;
if (b < 0) { if (b < 0) {
v = 0x3f - value->value.integer.value[0]; v = 0x3f - left;
b = (-b) | 0x40; b = (-b) | 0x40;
} else { } else {
v = 0x3f - value->value.integer.value[1]; v = 0x3f - right;
} }
/* Do we really know this will always be called with IRQs on? */ /* Do we really know this will always be called with IRQs on? */
spin_lock_irq(&chip->reg_lock); spin_lock_irq(&chip->reg_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment