[media] em28xx: Only deallocate struct em28xx after finishing all extensions
We can't free struct em28xx while one of the extensions is still using it. So, add a kref() to control it, freeing it only after the extensions fini calls. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
@@ -1043,7 +1043,6 @@ static int em28xx_dvb_init(struct em28xx *dev)
|
||||
em28xx_info("Binding DVB extension\n");
|
||||
|
||||
dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
|
||||
|
||||
if (dvb == NULL) {
|
||||
em28xx_info("em28xx_dvb: memory allocation failed\n");
|
||||
return -ENOMEM;
|
||||
@@ -1521,6 +1520,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
|
||||
dvb->adapter.mfe_shared = mfe_shared;
|
||||
|
||||
em28xx_info("DVB extension successfully initialized\n");
|
||||
|
||||
kref_get(&dev->ref);
|
||||
|
||||
ret:
|
||||
em28xx_set_mode(dev, EM28XX_SUSPEND);
|
||||
mutex_unlock(&dev->lock);
|
||||
@@ -1577,6 +1579,7 @@ static int em28xx_dvb_fini(struct em28xx *dev)
|
||||
em28xx_unregister_dvb(dvb);
|
||||
kfree(dvb);
|
||||
dev->dvb = NULL;
|
||||
kref_put(&dev->ref, em28xx_free_device);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Verwijs in nieuw issue
Block a user