[media] cx88-dvb avoid dangling core->gate_ctrl pointer
authorDavid Fries <david@fries.net>
Thu, 15 Dec 2011 04:59:20 +0000 (01:59 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 30 Dec 2011 19:38:15 +0000 (17:38 -0200)
dvb_register calls videobuf_dvb_register_bus, but if that returns
a failure the module will be unloaded without clearing the
value of core->gate_ctrl which will cause an oops in macros
called from video_open in cx88-video.c

Signed-off-by: David Fries <David@Fries.net>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Istvan Varga <istvan_v@mailbox.hu>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/cx88/cx88-dvb.c

index cf3d33ab541b8ee190dcd7fbdaefc6130895a002..396149824fcd947157b3137accc2a8566312cee5 100644 (file)
@@ -954,6 +954,7 @@ static int dvb_register(struct cx8802_dev *dev)
        struct cx88_core *core = dev->core;
        struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
        int mfe_shared = 0; /* bus not shared by default */
+       int res = -EINVAL;
 
        if (0 != core->i2c_rc) {
                printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
@@ -1566,13 +1567,16 @@ static int dvb_register(struct cx8802_dev *dev)
        call_all(core, core, s_power, 0);
 
        /* register everything */
-       return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
-                                        &dev->pci->dev, adapter_nr, mfe_shared, NULL);
+       res = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
+               &dev->pci->dev, adapter_nr, mfe_shared, NULL);
+       if (res)
+               goto frontend_detach;
+       return res;
 
 frontend_detach:
        core->gate_ctrl = NULL;
        videobuf_dvb_dealloc_frontends(&dev->frontends);
-       return -EINVAL;
+       return res;
 }
 
 /* ----------------------------------------------------------- */