From 3abdf420b1ad418454506df1dadfdfccb2d6e449 Mon Sep 17 00:00:00 2001 From: Mukund Madhusudan Atre Date: Mon, 17 Feb 2020 19:22:28 -0800 Subject: [PATCH] msm: camera: isp: Fix failure due to dereference of invalid ife device During reset of vfe hw, we are referencing an ife device which might not be available. Add condition to check ife device validity before reset. CRs-Fixed: 2584631 Change-Id: Ibf9e3e0a3696cf006977af60360a964748e8ef38 Signed-off-by: Mukund Madhusudan Atre --- drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c | 3 ++- drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index d12a375daf..033b201338 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -3948,7 +3948,8 @@ static int cam_ife_mgr_reset_vfe_hw(struct cam_ife_hw_mgr *hw_mgr, vfe_reset_type = CAM_VFE_HW_RESET_HW; for (i = 0; i < CAM_VFE_HW_NUM_MAX; i++) { - if (hw_idx != hw_mgr->ife_devices[i]->hw_idx) + if ((!hw_mgr->ife_devices[i]) || + (hw_idx != hw_mgr->ife_devices[i]->hw_idx)) continue; CAM_DBG(CAM_ISP, "VFE (id = %d) reset", hw_idx); vfe_hw_intf = hw_mgr->ife_devices[i]; diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c index 3f1376311c..1dfa48cbfb 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c @@ -14,7 +14,7 @@ #include "cam_vfe_soc.h" #include "cam_debug_util.h" -static struct cam_hw_intf *cam_vfe_hw_list[CAM_VFE_HW_NUM_MAX] = {0, 0, 0, 0}; +static struct cam_hw_intf *cam_vfe_hw_list[CAM_VFE_HW_NUM_MAX]; static char vfe_dev_name[8];