Skip to contentSkip to conversation

media: atomisp: Fix memory leak in atomisp_alloc_dis_coef_buf

PATCH In review Abdullah Mohammd Sifat 2 participants 2 messages Oct 27

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: atomisp: Fix memory leak in atomisp_alloc_dis_coef_buf

Free the allocated dvs2_coeff memory if ia_css_dvs2_statistics_allocate

fails to prevent a memory leak in the error path.

---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +5 -1
index eacd7ee5c050..48196a358ad9 100644
@@ -1373,8 +1373,12 @@ int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd)
 	/* DIS projections. */
 	asd->params.dis_proj_data_valid = false;
 	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;
 		return -ENOMEM;
+	}
+
 
 	asd->params.dvs_hor_proj_bytes =
 	    dvs_grid->aligned_height * dvs_grid->aligned_width *
Signature · 1 line
2.53.0
#1 lore raw
Quoted 5 lines · Abdullah Mohammd Sifat

Free the allocated dvs2_coeff memory if ia_css_dvs2_statistics_allocate

fails to prevent a memory leak in the error path.

The commit message says it is a bug but there is no Fixes tag.

However, it is not a bug because the memory is freed in the caller.

regards,
dan carpenter