Re: kobject_init_and_add() confusion

From: Greg Kroah-Hartman
Date: Thu May 02 2019 - 03:19:51 EST


On Thu, May 02, 2019 at 07:58:58AM +1000, Tobin C. Harding wrote:
> On Wed, May 01, 2019 at 01:10:22PM +0200, Greg Kroah-Hartman wrote:
> > On Wed, May 01, 2019 at 09:38:03AM +1000, Tobin C. Harding wrote:
> > > Hi,
> > >
> > > Looks like I've created a bit of confusion trying to fix memleaks in
> > > calls to kobject_init_and_add(). Its spread over various patches and
> > > mailing lists so I'm starting a new thread and CC'ing anyone that
> > > commented on one of those patches.
> > >
> > > If there is a better way to go about this discussion please do tell me.
> > >
> > > The problem
> > > -----------
> > >
> > > Calls to kobject_init_and_add() are leaking memory throughout the kernel
> > > because of how the error paths are handled.
> >
> > s/are leaking/have the potential to leak/
> >
> > Note, no one ever hits these error paths, so it isn't a big issue, and
> > is why no one has seen this except for the use of syzbot at times.
>
> One day I'll find an important issue to fix in the kernel. At the
> moment sweeping these up is good practice/learning. If you have any
> _real_ issues that need someone to turn the crank on feel free to dump
> them on me :)

Once you get this done, I do have some "fun" ideas about the cdev api
and how it can be "fixed up".

Your knowledge of reference counts and kobjects will come in handy
there, so talk to me off-list when you are ready :)

keep up the great work,

greg k-h