From: Lokesh Gupta Date: Fri, 11 Nov 2011 10:30:35 +0000 (+0100) Subject: [PORT FROM R2] atomisp: CSS tried to free memory that was already freed X-Git-Tag: 2.1b_release~1768 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bcc4e0941eb743cad82ef956d9a9d5a92d1176ec;p=kernel%2Fkernel-mfld-blackbay.git [PORT FROM R2] atomisp: CSS tried to free memory that was already freed BZ: 17272 Some pointers within the CSS code were not being initialized and reset correctly, due to which memory allocation/free-up caused warnings. This patch fixes these cases. A new function is added to properly uninitialize the sh_css_sp module. Change-Id: I885a7aeb2b77197562bc468a673c2653cc30f3fc Orig-Change-Id: I98370340392d3b7aca2f5c63403d3fbfe17164bd Signed-off-by: Lokesh Gupta Reviewed-on: http://android.intel.com:8080/23911 Reviewed-by: Wang, Wen W Reviewed-by: Koski, Anttu Reviewed-by: Cohen, David A Reviewed-by: Toivonen, Tuukka Reviewed-by: Von Oerthel, Jurgen Reviewed-by: Kruger, Jozef Tested-by: Koski, Anttu Reviewed-by: buildbot Tested-by: buildbot Reviewed-on: http://android.intel.com:8080/28011 Reviewed-by: Tuominen, TeemuX --- diff --git a/drivers/media/video/atomisp/css/sh_css.c b/drivers/media/video/atomisp/css/sh_css.c index 25f57ad..747917d 100644 --- a/drivers/media/video/atomisp/css/sh_css.c +++ b/drivers/media/video/atomisp/css/sh_css.c @@ -1766,6 +1766,7 @@ sh_css_uninit(void) /* cleanup generic data */ sh_css_params_uninit(); sh_css_binary_uninit(); + sh_css_sp_uninit(); if (my_css.sp_bin_addr) { hrt_isp_css_mm_free(my_css.sp_bin_addr); my_css.sp_bin_addr = NULL; diff --git a/drivers/media/video/atomisp/css/sh_css_params.c b/drivers/media/video/atomisp/css/sh_css_params.c index 71d5609..106fc6d 100644 --- a/drivers/media/video/atomisp/css/sh_css_params.c +++ b/drivers/media/video/atomisp/css/sh_css_params.c @@ -1785,12 +1785,11 @@ sh_css_params_reconfigure_gdc_lut(void) sh_css_hrt_gdc_set_lut(zoom_table); } -static void -safe_free(void *ptr) -{ - if (ptr) - hrt_isp_css_mm_free(ptr); -} +#define safe_free(x) do { \ + if (x) \ + hrt_isp_css_mm_free(x); \ + (x) = NULL; \ + } while (0) void sh_css_params_uninit(void) diff --git a/drivers/media/video/atomisp/css/sh_css_sp.c b/drivers/media/video/atomisp/css/sh_css_sp.c index 37e1899..d3398f3 100644 --- a/drivers/media/video/atomisp/css/sh_css_sp.c +++ b/drivers/media/video/atomisp/css/sh_css_sp.c @@ -67,6 +67,7 @@ sh_css_sp_store_init_dmem(const struct sh_css_sp_fw *fw) /* store data section to DDR */ if (init_dmem_ddr) hrt_isp_css_mm_free(init_dmem_ddr); + init_dmem_ddr = hrt_isp_css_mm_alloc(fw->data_size); hrt_isp_css_mm_store(init_dmem_ddr, fw->data, fw->data_size); @@ -84,6 +85,15 @@ sh_css_sp_store_init_dmem(const struct sh_css_sp_fw *fw) } void +sh_css_sp_uninit() +{ + if (init_dmem_ddr) { + hrt_isp_css_mm_free(init_dmem_ddr); + init_dmem_ddr = NULL; + } +} + +void sh_css_sp_start_histogram(struct sh_css_histogram *histogram, const struct sh_css_frame *frame) { diff --git a/drivers/media/video/atomisp/css/sh_css_sp.h b/drivers/media/video/atomisp/css/sh_css_sp.h index 30822ed..cbc41cf 100644 --- a/drivers/media/video/atomisp/css/sh_css_sp.h +++ b/drivers/media/video/atomisp/css/sh_css_sp.h @@ -39,6 +39,9 @@ void sh_css_sp_store_init_dmem(const struct sh_css_sp_fw *fw); void +sh_css_sp_uninit(); + +void sh_css_sp_start_histogram(struct sh_css_histogram *histogram, const struct sh_css_frame *frame);