Re: [PATCH][next] staging: media: atomisp: fix memory leak of object flash

From: Mauro Carvalho Chehab
Date: Thu Sep 03 2020 - 05:05:16 EST


Em Wed, 2 Sep 2020 21:15:31 +0300
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> escreveu:

> On Wed, Sep 2, 2020 at 8:02 PM Colin King <colin.king@xxxxxxxxxxxxx> wrote:
> >
> > From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
> >
> > In the case where the call to lm3554_platform_data_func returns an
> > error there is a memory leak on the error return path of object
> > flash. Fix this by adding an error return path that will free
> > flash and rename labels fail2 to fail3 and fail1 to fail2.
> >
>
> Wouldn't be proper fix to move to devm_kmalloc() and return
> dev_err_probe() where appropriate?

Actually, we prefer not using devm_*() at media subsystem.

Once we started migrating alloc stuff to use it. We end needing
to revert those, as it caused side effects related to lifecycle
management: some object were de-allocating too late. Others
with multiple interfaces (USB, pci) had even worse troubles.

Thanks,
Mauro