Re: [PATCH] Using a pointer and kzalloc in place of a struct directly

From: Greg KH
Date: Sat Sep 12 2020 - 11:02:40 EST


On Sat, Sep 12, 2020 at 05:43:38PM +0530, Anant Thazhemadam wrote:
>
> On 12/09/20 5:17 pm, Greg KH wrote:
> > Note, your "To:" line seemed corrupted, and why not cc: the bpf mailing
> > list as well?
> Oh, I'm sorry about that. I pulled the emails of all the people to whom
> this mail was sent off from the header in lkml mail, and just cc-ed
> everyone.
>
> > You leaked memory :(
> >
> > Did you test this patch? Where do you free this memory, I don't see
> > that happening anywhere in this patch, did I miss it?
>
> Yes, I did test this patch, which didn't seem to trigger any issues.
> It surprised me so much, that I ended up sending it in, to have
> it checked out.

You might not have noticed the memory leak if you were not looking for
it.

How did you test this?

> I wasn't sure where exactly the memory allocated here was
> supposed to be freed (might be why the current implementation
> isn't exactly using kzalloc). I forgot to mention it in the initial mail,
> and I was hoping that someone would point me in the right direction
> (if this approach was actually going to be considered, that is, which in
> retrospect I now feel might not be the best thing)

It has to be freed somewhere, you wrote the patch :)

But back to the original question here, why do you feel this change is
needed? What does this do better/faster/more correct than the code that
is currently there? Unless you can provide that, the change should not
be needed, right?

thanks,

greg k-h