Re: [PATCH] kobject: Ensure child's resources get released before parent's resources

Greg Kroah-Hartman
2015-12-14T21:40:24Z

On Mon, Dec 14, 2015 at 11:02:46AM -0800, Rajat Jain wrote:
> If the only remaining reference to a parent, is the one taken by
> the child (in kobject_add_internal()), then when the last
> reference to the child goes away, both child and its parents
> shall be released. However, currently the resources of parent
> get released first, followed by the child's resources:
>
> kobject_cleanup(child)
> ....
> kobject_del(child)
> ....
> kobject_put(child->parent) -> results in parent's release()
> ...
> child->kobj_type->release() -> Child's release()
>
> This is a problem because the child's release() method may still
> need to use parent resources or memory for its own cleanup. E.g.
> child may need parent pointer for dma_free_coherent() etc.
>
> Signed-off-by: Rajat Jain <rajatja@google.com>
> Signed-off-by: Rajat Jain <rajatxjain@gmail.com>

Why are you listed twice here?

Where in the kernel is the parent being freed before the child that is
causing this issue to happen? We should fix that root cause first...

thanks,

greg k-h