[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:
@@ -676,6 +676,8 @@ static int em28xx_ir_init(struct em28xx *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
kref_get(&dev->ref);
|
||||
|
||||
if (dev->board.buttons)
|
||||
em28xx_init_buttons(dev);
|
||||
|
||||
@@ -816,7 +818,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
|
||||
|
||||
/* skip detach on non attached boards */
|
||||
if (!ir)
|
||||
return 0;
|
||||
goto ref_put;
|
||||
|
||||
if (ir->rc)
|
||||
rc_unregister_device(ir->rc);
|
||||
@@ -824,6 +826,10 @@ static int em28xx_ir_fini(struct em28xx *dev)
|
||||
/* done */
|
||||
kfree(ir);
|
||||
dev->ir = NULL;
|
||||
|
||||
ref_put:
|
||||
kref_put(&dev->ref, em28xx_free_device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Fai riferimento in un nuovo problema
Block a user