Re: [RFD driver-core] Lifetime problems of the current driver model

Cornelia Huck
2007-03-30T13:38:40Z

On Fri, 30 Mar 2007 22:19:52 +0900,
Tejun Heo <htejun@gmail.com> wrote:

> > Shouldn't getting/putting the module refcount be solely done in
> > kobject.c? Grab the module reference when the kobject is created and
> > release the module reference in kobject_cleanup() after the release
> > function has been called. This doesn't make kobject_get() heavier, and
> > it ensures we don't delete the module until after the last kobject it is
> > supposed to clean up has been released.
>
> If we do that, we wouldn't be able to unload a module if there is any
> kobject referencing it even when the node has no openers, so no easy way
> out there. :-(

But we must not unload the module when there is still a kobject around
referencing a release function in the module, or we will oops if the
kobject is finally released. If needed, the module must clean up its
kobjects in its exit function.