[linux-dvb] Patch for PCTV200e driver solving "NULL pointer dereference"

Juan Antonio Garcia juanantonio_garcia_01 at yahoo.es
Sat Jul 14 09:44:01 CEST 2007

I have tested the patch below (included at the end) and seems to kill the "NULL
Pointer dereference" bug when initializing the PCTV200e driver.


reason I found for the bug is that in the function "pctv200e_frontend_attach" "adap->fe"
is NULL, and when the mt352 registration fails it continues being NULL.
When the mt2060 is attached using: "(adap->fe = dvb_attach(mt2060_attach, &adap->fe->ops.tuner_ops, &adap->dev->i2c_adap, &pctv200e_mt2060_config, if1)". The "&adap->fe->ops.tuner_ops" is non existent since "adap->fe" is null. And when in "mt2060.c"  the following line: 

    struct dvb_frontend *fe = ops->fe;


tries to reference the NULL pointer.

With this patch the initialization and deinitialization works fine.

I have tested it in a Ubuntu Kernel.

Any way in my PCTV200e tuner still non of the frontends is attached, I get: 

dvb-usb: no frontend was attached by 'Pinnacle PCTV 200e DVB-T'

Does anyone gets it attached?



Patch file:

--- pctv200e.c.orig    2007-07-14 09:43:49.000000000 +0300
+++ pctv200e.c    2007-07-14 10:33:26.000000000 +0300
@@ -159,20 +159,31 @@ static u16 if1 = 1220; // this is probab
 // source (for the tuner attach: dibusb-common.c)
 static int pctv200e_frontend_attach(struct dvb_usb_adapter *adap)
+    struct dvb_frontend *fe;
     if ((adap->fe = dvb_attach(mt352_attach, &pctv200e_mt352_config, &adap->dev->i2c_adap)) != NULL) {
         adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
         return 0;
-    } else
+    } else  {
         warn("frontend_attach failed (mt352)");
+        fe = kzalloc(sizeof(struct dvb_frontend), GFP_KERNEL);
+        if (fe == NULL)
+            return -EIO;
+        adap->fe = fe;    
+    }
     warn("next: attaching tuner.");
     if ((adap->fe = dvb_attach(mt2060_attach, &adap->fe->ops.tuner_ops, &adap->dev->i2c_adap, &pctv200e_mt2060_config, if1)) != NULL) {
         adap->fe->ops.tuner_ops.fe = adap->fe;
         adap->fe->ops.tuner_ops.set_params = pctv200e_mt2060_tuner_set_params;
         return 0;
-    }else
+    } else  {
+        kfree(fe);
         warn("frontend_attach failed (mt2060)");
+    }
     warn(" frontend attached.");
     return -EIO;

LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.linuxtv.org/pipermail/linux-dvb/attachments/20070714/f5767732/attachment.htm 

More information about the linux-dvb mailing list