patch(bttv-0.7.105) Fix tvaudio tda9874 oops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi,
tvaudio will oops for tda9874 chips when loaded with debug=1.

Cause: tda9874a_STD defaults to -1. Oopses when used as array index.
Fix:   Sanitize parameters

Regards, Gunther


--- bttv-0.7.105/driver/tvaudio.c	Fri Jan  3 18:23:44 2003
+++ bttv07105/driver/tvaudio.c	Sun Feb 16 12:34:14 2003
@@ -991,33 +991,39 @@
 
 static int tda9874a_initialize(struct CHIPSTATE *chip)
 {
-	if(tda9874a_SIF != -1) {
-		if(tda9874a_SIF == 1)
-			tda9874a_GCONR = 0xc0;	/* sound IF input 1 */
-		else if(tda9874a_SIF == 2)
-			tda9874a_GCONR = 0xc1;	/* sound IF input 2 */
-		else
-			printk(KERN_WARNING "tda9874a: SIF parameter must be 1 or 2.\n");
+
+	dprintk("tda9874a_initialize\n");
+
+	if(tda9874a_SIF<1 || tda9874a_SIF>2) {
+		printk(KERN_WARNING "tda9874a_SIF parameter must be 1 or 2. Assuming 1.\n");
+		tda9874a_SIF=1;
+	}
+
+	if(tda9874a_SIF == 1)
+		tda9874a_GCONR = 0xc0;	/* sound IF input 1 */
+	else if(tda9874a_SIF == 2)
+		tda9874a_GCONR = 0xc1;	/* sound IF input 2 */
+
+	if(tda9874a_STD<0 || tda9874a_STD>8) {
+		printk(KERN_WARNING "tda9874a_STD parameter must be between 0 and 8. Assuming 0.\n");
+		tda9874a_STD=0;
 	}
 
-	if(tda9874a_STD != -1) {
-		if((tda9874a_STD >= 0)&&(tda9874a_STD <= 8)) {
-			tda9874a_ESP = tda9874a_STD;
-			tda9874a_mode = (tda9874a_STD < 5) ? 0 : 1;
-		} else {
-			printk(KERN_WARNING "tda9874a: STD parameter must be between 0 and 8.\n");
-		}
+	if((tda9874a_STD >= 0)&&(tda9874a_STD <= 8)) {
+		tda9874a_ESP = tda9874a_STD;
+		tda9874a_mode = (tda9874a_STD < 5) ? 0 : 1;
 	}
 
-	if(tda9874a_AMSEL != -1) {
-		if(tda9874a_AMSEL == 0)
-			tda9874a_NCONR = 0x01; /* auto-mute: analog mono input */
-		else if(tda9874a_AMSEL == 1)
-			tda9874a_NCONR = 0x05; /* auto-mute: 1st carrier FM or AM */
-		else
-			printk(KERN_WARNING "tda9874a: AMSEL parameter must be 0 or 1.\n");
+	if(tda9874a_AMSEL<0 || tda9874a_AMSEL>1) {
+		printk(KERN_WARNING "tda9874a: AMSEL parameter must be 0 or 1. Assuming 0\n");
+		tda9874a_AMSEL=0;
 	}
 
+	if(tda9874a_AMSEL == 0)
+		tda9874a_NCONR = 0x01; /* auto-mute: analog mono input */
+	else if(tda9874a_AMSEL == 1)
+		tda9874a_NCONR = 0x05; /* auto-mute: 1st carrier FM or AM */
+
 	tda9874a_setup(chip);
 
 	return 0;

[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux