diff mbox

cx88-alsa: prevent out-of-range volume setting

Message ID 4B825223.7030904@ladisch.de (mailing list archive)
State Accepted
Headers show

Commit Message

Clemens Ladisch Feb. 22, 2010, 9:45 a.m. UTC
None
diff mbox

Patch

--- linux/drivers/media/video/cx88/cx88-alsa.c
+++ linux/drivers/media/video/cx88/cx88-alsa.c
@@ -583,16 +583,18 @@  static int snd_cx88_volume_put(struct sn
 {
 	snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
 	struct cx88_core *core=chip->core;
-	int v, b;
+	int left, right, v, b;
 	int changed = 0;
 	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) {
-	    v = 0x3f - value->value.integer.value[0];
+	    v = 0x3f - left;
 	    b = (-b) | 0x40;
 	} else {
-	    v = 0x3f - value->value.integer.value[1];
+	    v = 0x3f - right;
 	}
 	/* Do we really know this will always be called with IRQs on? */
 	spin_lock_irq(&chip->reg_lock);