[media] dvb-usb-v2: postpone removal of media_device
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 29 Dec 2015 18:45:21 +0000 (16:45 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:26 +0000 (12:19 -0200)
We should not remove the media_device until its last usage,
or we may have use after free troubles.

So, move the per-adapter media_device removal to happen at
the end of the adapter removal code.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c

index e8491f73c0d9a0e2bcad8e06735bc72cd2684a1b..f0565bf3673e8687ba16599aafc59152ad85f1da 100644 (file)
@@ -542,7 +542,6 @@ static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap)
                adap->demux.dmx.close(&adap->demux.dmx);
                dvb_dmxdev_release(&adap->dmxdev);
                dvb_dmx_release(&adap->demux);
-               dvb_usbv2_media_device_unregister(adap);
                dvb_unregister_adapter(&adap->dvb_adap);
        }
 
@@ -852,6 +851,7 @@ static int dvb_usbv2_adapter_exit(struct dvb_usb_device *d)
                        dvb_usbv2_adapter_dvb_exit(&d->adapter[i]);
                        dvb_usbv2_adapter_stream_exit(&d->adapter[i]);
                        dvb_usbv2_adapter_frontend_exit(&d->adapter[i]);
+                       dvb_usbv2_media_device_unregister(&d->adapter[i]);
                }
        }