[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:
Mauro Carvalho Chehab
2014-03-05 11:21:07 -03:00
parent 88e4fcda55
commit 47677e51e2
6 ha cambiato i file con 56 aggiunte e 19 eliminazioni

Vedi File

@@ -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;
}