Re: [PATCH v2] staging: media: atomisp: fix memory leak of dvs2_coeff
From: Andy Shevchenko
Date: Thu Apr 16 2026 - 14:33:12 EST
On Thu, Apr 16, 2026 at 09:16:26PM +0800, Huihui Huang wrote:
> There is a memory leak in
> drivers/staging/media/atomisp/pci/atomisp_compat_css20.c.
>
> In atomisp_alloc_dis_coef_buf(), dvs2_coeff is allocated by
> ia_css_dvs2_coefficients_allocate() and stored in
> asd->params.css_param.dvs2_coeff. If the subsequent
> ia_css_dvs2_statistics_allocate() for dvs_stat fails, the function
> returns -ENOMEM without freeing the previously allocated dvs2_coeff.
> Add the missing ia_css_dvs2_coefficients_free() call and set the
> pointer to NULL before returning on the error path.
Why do we need this?
...
> asd->params.dvs_stat = ia_css_dvs2_statistics_allocate(dvs_grid);
> - if (!asd->params.dvs_stat)
> + if (!asd->params.dvs_stat) {
> + ia_css_dvs2_coefficients_free(asd->params.css_param.dvs2_coeff);
> + asd->params.css_param.dvs2_coeff = NULL;
Actually same Q here: Do we need this NULLification?
> return -ENOMEM;
> + }
--
With Best Regards,
Andy Shevchenko