Re: EDAC: Fix memory leak in creating CSROW object

From: Borislav Petkov
Date: Thu Apr 18 2019 - 20:45:25 EST


On Fri, Apr 19, 2019 at 08:35:36AM +0800, PanBian wrote:
> Yes, I see that. Because the loop start with (--i), there is no put
> operation for the device that fails to create. So, I think we cannot
> rule out the possibility of memory leak.

Ok, so this is not something you trigger - you're basically staring at
the code?

Well, there's something else questionable in that code which I asked
Greg about today but we didn't finish that conversation, let me CC him.

So AFAIU, devices for which device_add() has returned success,
should be removed with their counterpart device_del().
edac_create_csrow_objects(), however, does put_device() on those in the
"unwinding" loop.

And for the case where device_add() fails, you should do put_device() to
it. I.e., what you're saying.

So I think we need to figure what needs to be done when before fixing
this properly.

Greg?

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.