From a5e1ad91b4c3f9e2b625c2a653a1d9dea1465ccd Mon Sep 17 00:00:00 2001 From: Atiya Kailany Date: Thu, 16 Mar 2023 15:56:29 -0700 Subject: [PATCH] msm: camera: common: Fixing memory leak issues and removing dead code Fixed null pointer dereference, addressed memroy management issues and removed unused variabels CRs-Fixed: 3394193 Change-Id: I477d4b8ea781b20b5b2a66331bebb384e1c703c5 Signed-off-by: Atiya Kailany --- drivers/cam_cpas/cam_cpas_intf.c | 7 ---- drivers/cam_cpas/cam_cpas_soc.c | 6 ++- .../icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c | 10 ++--- drivers/cam_isp/cam_isp_context.c | 1 - drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c | 3 -- .../isp_hw/ife_csid_hw/cam_ife_csid_hw_ver1.c | 3 +- .../isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c | 38 ++--------------- .../isp_hw/sfe_hw/sfe_top/cam_sfe_top.c | 2 - .../isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c | 20 +++------ .../isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver3.c | 2 - .../isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c | 2 +- .../cam_eeprom/cam_eeprom_core.c | 2 + .../cam_flash/cam_flash_core.c | 33 +-------------- .../cam_flash/cam_flash_dev.c | 10 +++-- .../cam_sensor_io/cam_sensor_spi.c | 18 +++++--- .../cam_sensor_utils/cam_sensor_util.c | 3 +- drivers/cam_utils/cam_soc_util.c | 41 +++++++++---------- 17 files changed, 64 insertions(+), 137 deletions(-) diff --git a/drivers/cam_cpas/cam_cpas_intf.c b/drivers/cam_cpas/cam_cpas_intf.c index ea525a70ca..f692c1c01c 100644 --- a/drivers/cam_cpas/cam_cpas_intf.c +++ b/drivers/cam_cpas/cam_cpas_intf.c @@ -892,19 +892,12 @@ int cam_cpas_configure_staling_llcc( uint32_t staling_distance) { int rc; - struct cam_hw_info *cpas_hw = NULL; - struct cam_cpas_private_soc *soc_private = NULL; - uint32_t num_caches = 0; struct cam_sys_cache_local_info sys_cache_info; if (!CAM_CPAS_INTF_INITIALIZED()) { CAM_ERR(CAM_CPAS, "cpas intf not initialized"); return -ENODEV; } - cpas_hw = (struct cam_hw_info *) g_cpas_intf->hw_intf->hw_priv; - soc_private = - (struct cam_cpas_private_soc *)cpas_hw->soc_info.soc_private; - num_caches = soc_private->num_caches; if (!cam_cpas_is_notif_staling_supported()) return -EOPNOTSUPP; diff --git a/drivers/cam_cpas/cam_cpas_soc.c b/drivers/cam_cpas/cam_cpas_soc.c index 4cdbc07033..4fdb3b3b12 100644 --- a/drivers/cam_cpas/cam_cpas_soc.c +++ b/drivers/cam_cpas/cam_cpas_soc.c @@ -1734,6 +1734,8 @@ int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info, goto release_res; } + soc_private = (struct cam_cpas_private_soc *)soc_info->soc_private; + rc = cam_cpas_get_custom_dt_info(cpas_hw, soc_info->pdev, soc_info->soc_private); if (rc) { @@ -1741,8 +1743,6 @@ int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info, goto free_soc_private; } - soc_private = (struct cam_cpas_private_soc *)soc_info->soc_private; - soc_info->is_clk_drv_en = soc_private->enable_cam_clk_drv; rc = cam_soc_util_get_option_clk_by_name(soc_info, CAM_ICP_CLK_NAME, @@ -1766,6 +1766,8 @@ int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info, return rc; free_soc_private: + kfree(soc_private->llcc_info); + kfree(soc_private->smart_qos_info); kfree(soc_info->soc_private); release_res: cam_soc_util_release_platform_resource(soc_info); diff --git a/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c b/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c index 2cb50e6527..418181dd72 100644 --- a/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +++ b/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c @@ -2800,8 +2800,8 @@ static int cam_icp_mgr_process_ofe_indirect_ack_msg(uint32_t *msg_ptr) ioconfig_ack = (struct hfi_msg_dev_async_ack *)msg_ptr; ctx_data = U64_TO_PTR(ioconfig_ack->user_data1); - hw_mgr = ctx_data->hw_mgr_priv; if (cam_presil_mode_enabled()) { + hw_mgr = ctx_data->hw_mgr_priv; if (atomic_read(&hw_mgr->frame_in_process)) { if (hw_mgr->frame_in_process_ctx_id == ctx_data->ctx_id) { CAM_DBG(CAM_PRESIL, "presil: frame process abort ctx %d", @@ -2862,9 +2862,9 @@ static int cam_icp_mgr_process_direct_ack_msg(uint32_t *msg_ptr) ioconfig_ack = (struct hfi_msg_dev_async_ack *)msg_ptr; ctx_data = (struct cam_icp_hw_ctx_data *) U64_TO_PTR(ioconfig_ack->user_data1); - hw_mgr = ctx_data->hw_mgr_priv; if (cam_presil_mode_enabled()) { + hw_mgr = ctx_data->hw_mgr_priv; if (atomic_read(&hw_mgr->frame_in_process)) { if (hw_mgr->frame_in_process_ctx_id == ctx_data->ctx_id) { CAM_DBG(CAM_PRESIL, "%s: presil: frame process abort", @@ -3073,9 +3073,6 @@ static void cam_icp_mgr_process_dbg_buf(struct cam_icp_hw_mgr *hw_mgr) return; msg_ptr += (pkt_ptr[ICP_PACKET_SIZE] >> BYTE_WORD_SHIFT); - pkt_ptr = NULL; - dbg_msg = NULL; - dbg_buf = NULL; } } @@ -7294,7 +7291,8 @@ static int cam_icp_mgr_alloc_devs(struct device_node *np, CAM_ERR(CAM_ICP, "[%s] Invalid hw dev type: %u", hw_mgr->hw_mgr_name, icp_hw_type); rc = -EINVAL; - goto free_devs; + kfree(devices); + return rc; } hw_mgr->devices[icp_hw_type] = devices; diff --git a/drivers/cam_isp/cam_isp_context.c b/drivers/cam_isp/cam_isp_context.c index d93bf59c5f..917a630056 100644 --- a/drivers/cam_isp/cam_isp_context.c +++ b/drivers/cam_isp/cam_isp_context.c @@ -3824,7 +3824,6 @@ end: do { if (list_empty(&ctx->pending_req_list)) { error_request_id = ctx_isp->last_applied_req_id; - req_isp = NULL; break; } req = list_first_entry(&ctx->pending_req_list, 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 fd56ee1cda..8a1cb9ff1c 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 @@ -1949,7 +1949,6 @@ static int cam_ife_mgr_process_base_info( struct cam_isp_hw_mgr_res *hw_mgr_res; struct cam_isp_resource_node *res = NULL; uint32_t i; - struct cam_ife_hw_mgr *hw_mgr; bool hw_idx_map[CAM_IFE_CSID_HW_NUM_MAX] = {0}; if (list_empty(&ctx->res_list_ife_src) && @@ -1958,8 +1957,6 @@ static int cam_ife_mgr_process_base_info( return -ENODEV; } - hw_mgr = ctx->hw_mgr; - /* IFE mux in resources */ list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) { if (hw_mgr_res->res_type == CAM_ISP_RESOURCE_UNINT) diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver1.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver1.c index 6b1987fafb..66aa32c509 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver1.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver1.c @@ -4201,8 +4201,6 @@ static int cam_ife_csid_ver1_bottom_half_handler( if (!evt_payload->irq_status[i]) continue; - path_reg = NULL; - switch (i) { case CAM_IFE_CSID_IRQ_REG_IPP: path_reg = csid_reg->ipp_reg; @@ -4225,6 +4223,7 @@ static int cam_ife_csid_ver1_bottom_half_handler( path_reg = csid_reg->udi_reg[id]; break; default: + path_reg = NULL; break; } diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c index 671c53d0b2..ea6966c1f5 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c @@ -501,7 +501,6 @@ static int cam_ife_csid_ver2_path_err_top_half( struct cam_ife_csid_ver2_hw *csid_hw = NULL; struct cam_ife_csid_ver2_evt_payload *evt_payload; struct cam_isp_resource_node *res; - struct cam_ife_csid_ver2_reg_info *csid_reg = NULL; const uint8_t **irq_reg_tag; struct cam_ife_csid_ver2_path_cfg *path_cfg; @@ -514,8 +513,6 @@ static int cam_ife_csid_ver2_path_err_top_half( hw_info = (struct cam_hw_info *)res->hw_intf->hw_priv; csid_hw = (struct cam_ife_csid_ver2_hw *)hw_info->core_info; - csid_reg = (struct cam_ife_csid_ver2_reg_info *) - csid_hw->core_info->csid_reg; path_cfg = (struct cam_ife_csid_ver2_path_cfg *)res->res_priv; rc = cam_ife_csid_ver2_get_evt_payload(csid_hw, &evt_payload, @@ -553,7 +550,6 @@ static int cam_ife_csid_ver2_path_top_half( struct cam_ife_csid_ver2_hw *csid_hw = NULL; struct cam_ife_csid_ver2_evt_payload *evt_payload; struct cam_isp_resource_node *res; - struct cam_ife_csid_ver2_reg_info *csid_reg = NULL; const uint8_t **irq_reg_tag; struct cam_ife_csid_ver2_path_cfg *path_cfg; @@ -566,8 +562,6 @@ static int cam_ife_csid_ver2_path_top_half( hw_info = (struct cam_hw_info *)res->hw_intf->hw_priv; csid_hw = (struct cam_ife_csid_ver2_hw *)hw_info->core_info; - csid_reg = (struct cam_ife_csid_ver2_reg_info *) - csid_hw->core_info->csid_reg; path_cfg = (struct cam_ife_csid_ver2_path_cfg *)res->res_priv; rc = cam_ife_csid_ver2_get_evt_payload(csid_hw, &evt_payload, @@ -784,12 +778,6 @@ end: static int cam_ife_csid_ver2_stop_csi2_in_err( struct cam_ife_csid_ver2_hw *csid_hw) { - const struct cam_ife_csid_ver2_reg_info *csid_reg; - struct cam_hw_soc_info *soc_info; - - soc_info = &csid_hw->hw_info->soc_info; - csid_reg = (struct cam_ife_csid_ver2_reg_info *) - csid_hw->core_info->csid_reg; CAM_DBG(CAM_ISP, "CSID:%u Stop csi2 rx", csid_hw->hw_intf->hw_idx); @@ -904,12 +892,6 @@ static int cam_ife_csid_ver2_disable_csi2( bool maskout_irqs, struct cam_ife_csid_ver2_hw *csid_hw) { - const struct cam_ife_csid_ver2_reg_info *csid_reg; - struct cam_hw_soc_info *soc_info; - - soc_info = &csid_hw->hw_info->soc_info; - csid_reg = (struct cam_ife_csid_ver2_reg_info *) - csid_hw->core_info->csid_reg; CAM_DBG(CAM_ISP, "CSID:%u Disable csi2 rx", csid_hw->hw_intf->hw_idx); @@ -1924,7 +1906,6 @@ static int cam_ife_csid_ver2_ipp_bottom_half( uint32_t irq_status_ipp; uint32_t err_mask; uint32_t err_type = 0; - void __iomem *base; int rc = 0; bool out_of_sync_fatal = false; @@ -1941,7 +1922,6 @@ static int cam_ife_csid_ver2_ipp_bottom_half( csid_hw = (struct cam_ife_csid_ver2_hw *)hw_info->core_info; csid_reg = csid_hw->core_info->csid_reg; soc_info = &csid_hw->hw_info->soc_info; - base = soc_info->reg_map[CAM_IFE_CSID_CLC_MEM_BASE_ID].mem_base; path_cfg = (struct cam_ife_csid_ver2_path_cfg *)res->res_priv; if (!path_cfg || (path_cfg->irq_reg_idx >= CAM_IFE_CSID_IRQ_REG_MAX)) { @@ -2044,7 +2024,6 @@ static int cam_ife_csid_ver2_ppp_bottom_half( struct cam_ife_csid_ver2_hw *csid_hw = NULL; struct cam_hw_soc_info *soc_info; struct cam_hw_info *hw_info; - void __iomem *base; uint32_t irq_status_ppp; uint32_t err_mask; uint32_t err_type = 0; @@ -2062,7 +2041,6 @@ static int cam_ife_csid_ver2_ppp_bottom_half( hw_info = (struct cam_hw_info *)res->hw_intf->hw_priv; csid_hw = (struct cam_ife_csid_ver2_hw *)hw_info->core_info; soc_info = &csid_hw->hw_info->soc_info; - base = soc_info->reg_map[CAM_IFE_CSID_CLC_MEM_BASE_ID].mem_base; path_cfg = (struct cam_ife_csid_ver2_path_cfg *)res->res_priv; if (!path_cfg || (path_cfg->irq_reg_idx >= CAM_IFE_CSID_IRQ_REG_MAX)) { @@ -2129,7 +2107,6 @@ static int cam_ife_csid_ver2_rdi_bottom_half( const struct cam_ife_csid_ver2_path_reg_info *rdi_reg; struct cam_hw_soc_info *soc_info; struct cam_hw_info *hw_info; - void __iomem *base; uint32_t irq_status_rdi; uint32_t err_mask; uint32_t err_type = 0; @@ -2163,7 +2140,6 @@ static int cam_ife_csid_ver2_rdi_bottom_half( csid_reg = (struct cam_ife_csid_ver2_reg_info *) csid_hw->core_info->csid_reg; soc_info = &csid_hw->hw_info->soc_info; - base = soc_info->reg_map[CAM_IFE_CSID_CLC_MEM_BASE_ID].mem_base; irq_status_rdi = payload->irq_reg_val; rdi_reg = csid_reg->path_reg[res->res_id]; @@ -3043,10 +3019,6 @@ static int cam_ife_csid_ver2_in_port_validate( struct cam_ife_csid_ver2_hw *csid_hw) { int rc = 0; - struct cam_ife_csid_ver2_reg_info *csid_reg; - - csid_reg = (struct cam_ife_csid_ver2_reg_info *) - csid_hw->core_info->csid_reg; /* check in port args for RT streams*/ if (!reserve->is_offline) { @@ -3596,7 +3568,6 @@ static int cam_ife_csid_ver2_init_config_pxl_path( cam_io_w_mb(val, mem_base + path_reg->multi_vcdt_cfg0_addr); } - val = 0; /*configure cfg1 addr * Binning * Crop/Drop parameters @@ -4381,7 +4352,6 @@ static int cam_ife_csid_ver2_enable_csi2(struct cam_ife_csid_ver2_hw *csid_hw) CAM_DBG(CAM_ISP, "CSID[%u] rx_cfg0: 0x%x", csid_hw->hw_intf->hw_idx, val); - val = 0; /*Configure Rx cfg1*/ val = 1 << csi2_reg->misr_enable_shift_val; val |= 1 << csi2_reg->ecc_correction_shift_en; @@ -6064,8 +6034,6 @@ static int cam_ife_csid_ver2_user_dump( struct cam_ife_csid_ver2_path_cfg *path_cfg; struct cam_isp_resource_node *res; struct cam_isp_hw_dump_args *dump_args; - struct cam_ife_csid_ver2_reg_info *csid_reg; - struct cam_hw_soc_info *soc_info; int rc = 0; if (!csid_hw || !cmd_args) { @@ -6079,8 +6047,6 @@ static int cam_ife_csid_ver2_user_dump( } dump_args = (struct cam_isp_hw_dump_args *)cmd_args; - csid_reg = (struct cam_ife_csid_ver2_reg_info *)csid_hw->core_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; rc = cam_common_user_dump_helper(dump_args, cam_common_user_dump_clock, csid_hw->hw_info, sizeof(uint64_t), "CLK_RATE_PRINT:"); @@ -6895,6 +6861,10 @@ int cam_ife_csid_hw_ver2_init(struct cam_hw_intf *hw_intf, csid_hw->hw_intf->hw_ops.test_irq_line = cam_ife_csid_ver2_irq_line_test; rc = cam_ife_csid_hw_init_irq(csid_hw); + if (rc) { + CAM_ERR(CAM_ISP, "Failed to init CSID irq"); + return rc; + } rc = cam_ife_csid_ver2_hw_init_path_res(csid_hw); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_top/cam_sfe_top.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_top/cam_sfe_top.c index 071c10b51e..628de66167 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_top/cam_sfe_top.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_top/cam_sfe_top.c @@ -1647,7 +1647,6 @@ int cam_sfe_top_start( struct cam_isp_resource_node *sfe_res; struct cam_hw_info *hw_info = NULL; struct cam_sfe_path_data *path_data; - struct cam_hw_soc_info *soc_info = NULL; uint32_t error_mask[CAM_SFE_IRQ_REGISTERS_MAX]; uint32_t sof_eof_mask[CAM_SFE_IRQ_REGISTERS_MAX]; uint32_t core_cfg = 0, i = 0; @@ -1659,7 +1658,6 @@ int cam_sfe_top_start( top_priv = (struct cam_sfe_top_priv *)priv; sfe_res = (struct cam_isp_resource_node *) start_args; - soc_info = top_priv->common_data.soc_info; hw_info = (struct cam_hw_info *)sfe_res->hw_intf->hw_priv; if (!hw_info) { diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c index 91fcf19d90..544768ce98 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c @@ -505,7 +505,7 @@ static int cam_vfe_fe_handle_irq_top_half(uint32_t evt_id, static int cam_vfe_fe_handle_irq_bottom_half(void *handler_priv, void *evt_payload_priv) { - int ret = CAM_VFE_IRQ_STATUS_ERR; + int ret = CAM_VFE_IRQ_STATUS_SUCCESS; struct cam_isp_resource_node *fe_node; struct cam_vfe_mux_fe_data *fe_priv; struct cam_vfe_top_irq_evt_payload *payload; @@ -514,6 +514,7 @@ static int cam_vfe_fe_handle_irq_bottom_half(void *handler_priv, if (!handler_priv || !evt_payload_priv) { CAM_ERR(CAM_ISP, "Invalid params"); + ret = CAM_VFE_IRQ_STATUS_ERR; return ret; } @@ -541,31 +542,22 @@ static int cam_vfe_fe_handle_irq_bottom_half(void *handler_priv, } else { CAM_DBG(CAM_ISP, "Received SOF"); } - ret = CAM_VFE_IRQ_STATUS_SUCCESS; } - if (irq_status0 & fe_priv->reg_data->epoch0_irq_mask) { + if (irq_status0 & fe_priv->reg_data->epoch0_irq_mask) CAM_DBG(CAM_ISP, "Received EPOCH"); - ret = CAM_VFE_IRQ_STATUS_SUCCESS; - } - if (irq_status0 & fe_priv->reg_data->reg_update_irq_mask) { + if (irq_status0 & fe_priv->reg_data->reg_update_irq_mask) CAM_DBG(CAM_ISP, "Received REG_UPDATE_ACK"); - ret = CAM_VFE_IRQ_STATUS_SUCCESS; - } - if (irq_status0 & fe_priv->reg_data->eof_irq_mask) { + if (irq_status0 & fe_priv->reg_data->eof_irq_mask) CAM_DBG(CAM_ISP, "Received EOF"); - ret = CAM_VFE_IRQ_STATUS_SUCCESS; - } if (irq_status1 & fe_priv->reg_data->error_irq_mask1) { CAM_DBG(CAM_ISP, "Received ERROR"); - ret = CAM_ISP_HW_ERROR_OVERFLOW; + ret = CAM_VFE_IRQ_STATUS_ERR; cam_vfe_fe_reg_dump(fe_node); /* No HW mgr notification on error */ - } else { - ret = CAM_ISP_HW_ERROR_NONE; } CAM_DBG(CAM_ISP, "returing status = %d", ret); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver3.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver3.c index 65d2c6c1a1..8d9193826d 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver3.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver3.c @@ -591,8 +591,6 @@ int cam_vfe_top_ver3_stop(void *device_priv, top_priv = (struct cam_vfe_top_ver3_priv *)device_priv; mux_res = (struct cam_isp_resource_node *)stop_args; - soc_info = top_priv->top_common.soc_info; - soc_info = top_priv->top_common.soc_info; soc_private = soc_info->soc_private; diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c index 9b5f73576c..715b890afe 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c @@ -182,7 +182,7 @@ static int cam_vfe_top_ver4_pdaf_lcr_config(struct cam_vfe_top_ver4_priv *top_pr } reg_val_pair[reg_val_idx++] = hw_info->common_reg->pdaf_input_cfg_0; - reg_val_pair[reg_val_idx++] = hw_info->pdaf_lcr_res_mask[i].val; + reg_val_pair[reg_val_idx] = hw_info->pdaf_lcr_res_mask[i].val; cdm_util_ops->cdm_write_regrandom(cdm_args->cmd.cmd_buf_addr, num_reg_vals, reg_val_pair); cdm_args->cmd.used_bytes = size * 4; diff --git a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c index d579504379..596d0058ac 100644 --- a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c +++ b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c @@ -601,6 +601,7 @@ static int32_t cam_eeprom_handle_continuous_write( if (i2c_list == NULL || i2c_list->seq_settings.reg_data == NULL) { CAM_ERR(CAM_SENSOR, "Failed in allocating i2c_list"); + kfree(i2c_list); return -ENOMEM; } @@ -643,6 +644,7 @@ static int32_t cam_eeprom_handle_continuous_write( *list = &(i2c_list->list); return rc; deallocate_i2c_list: + kfree(i2c_list->seq_settings.reg_data); kfree(i2c_list); return rc; } diff --git a/drivers/cam_sensor_module/cam_flash/cam_flash_core.c b/drivers/cam_sensor_module/cam_flash/cam_flash_core.c index 6d76d9cfd5..58898ec64d 100644 --- a/drivers/cam_sensor_module/cam_flash/cam_flash_core.c +++ b/drivers/cam_sensor_module/cam_flash/cam_flash_core.c @@ -933,8 +933,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) int rc = 0, i = 0; uintptr_t generic_ptr; uint32_t total_cmd_buf_in_bytes = 0; - uint32_t processed_cmd_buf_in_bytes = 0; - uint16_t cmd_length_in_bytes = 0; uint32_t *cmd_buf = NULL; uint32_t *offset = NULL; uint32_t frm_offset = 0; @@ -1012,7 +1010,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) /* Loop through multiple command buffers */ for (i = 1; i < csl_packet->num_cmd_buf; i++) { total_cmd_buf_in_bytes = cmd_desc[i].length; - processed_cmd_buf_in_bytes = 0; if (!total_cmd_buf_in_bytes) continue; rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle, @@ -1040,9 +1037,8 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) /* Loop through cmd formats in one cmd buffer */ CAM_DBG(CAM_FLASH, - "command Type: %d,Processed: %d,Total: %d", - cmn_hdr->cmd_type, processed_cmd_buf_in_bytes, - total_cmd_buf_in_bytes); + "command Type: %d,Total: %d", + cmn_hdr->cmd_type, total_cmd_buf_in_bytes); switch (cmn_hdr->cmd_type) { case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO: if (len_of_buffer < @@ -1053,12 +1049,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) flash_init = (struct cam_flash_init *)cmd_buf; fctrl->flash_type = flash_init->flash_type; - cmd_length_in_bytes = - sizeof(struct cam_flash_init); - processed_cmd_buf_in_bytes += - cmd_length_in_bytes; - cmd_buf += cmd_length_in_bytes/ - sizeof(uint32_t); break; case CAMERA_SENSOR_CMD_TYPE_I2C_INFO: rc = cam_flash_slaveInfo_pkt_parser( @@ -1069,27 +1059,15 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) rc); return rc; } - cmd_length_in_bytes = - sizeof(struct cam_cmd_i2c_info); - processed_cmd_buf_in_bytes += - cmd_length_in_bytes; - cmd_buf += cmd_length_in_bytes/ - sizeof(uint32_t); break; case CAMERA_SENSOR_CMD_TYPE_PWR_UP: case CAMERA_SENSOR_CMD_TYPE_PWR_DOWN: CAM_DBG(CAM_FLASH, "Received power settings"); - cmd_length_in_bytes = - total_cmd_buf_in_bytes; rc = cam_sensor_update_power_settings( cmd_buf, total_cmd_buf_in_bytes, &fctrl->power_info, remain_len); - processed_cmd_buf_in_bytes += - cmd_length_in_bytes; - cmd_buf += cmd_length_in_bytes/ - sizeof(uint32_t); if (rc) { CAM_ERR(CAM_FLASH, "Failed update power settings"); @@ -1113,13 +1091,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) "pkt parsing failed: %d", rc); return rc; } - cmd_length_in_bytes = - cmd_desc[i].length; - processed_cmd_buf_in_bytes += - cmd_length_in_bytes; - cmd_buf += cmd_length_in_bytes/ - sizeof(uint32_t); - break; } } diff --git a/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c b/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c index fa0263f4f9..cc019ad1a8 100644 --- a/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c +++ b/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c @@ -641,7 +641,7 @@ static int cam_flash_i2c_component_bind(struct device *dev, rc = rc ? rc : -EINVAL; CAM_ERR(CAM_FLASH, "get failed for regulator %s %d", soc_info->rgltr_name[i], rc); - goto free_ctrl; + goto free_ctrl_cci_client; } CAM_DBG(CAM_FLASH, "get for regulator %s", soc_info->rgltr_name[i]); @@ -653,7 +653,7 @@ static int cam_flash_i2c_component_bind(struct device *dev, if (!soc_info->gpio_data->cam_gpio_common_tbl_size) { CAM_DBG(CAM_FLASH, "No GPIO found"); rc = -EINVAL; - goto free_ctrl; + goto free_ctrl_cci_client; } rc = cam_sensor_util_init_gpio_pin_tbl(soc_info, @@ -661,13 +661,13 @@ static int cam_flash_i2c_component_bind(struct device *dev, if ((rc < 0) || (!fctrl->power_info.gpio_num_info)) { CAM_ERR(CAM_FLASH, "No/Error Flash GPIOs"); rc = -EINVAL; - goto free_ctrl; + goto free_ctrl_cci_client; } } rc = cam_flash_init_subdev(fctrl); if (rc) - goto free_ctrl; + goto free_ctrl_cci_client; fctrl->i2c_data.per_frame = kzalloc(sizeof(struct i2c_settings_array) * @@ -704,6 +704,8 @@ static int cam_flash_i2c_component_bind(struct device *dev, unreg_subdev: cam_unregister_subdev(&(fctrl->v4l2_dev_str)); +free_ctrl_cci_client: + kfree(fctrl->io_master_info.cci_client); free_ctrl: kfree(fctrl); fctrl = NULL; diff --git a/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c b/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c index 7b1ef97085..e55ce75111 100644 --- a/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c +++ b/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c @@ -421,11 +421,19 @@ static int32_t cam_spi_page_program(struct camera_io_master *client, memcpy(tx + header_len, data, len); CAM_DBG(CAM_SENSOR, "tx(%u): %02x %02x %02x %02x", len, tx[0], tx[1], tx[2], tx[3]); - while ((rc = spi_write(spi, tx, len + header_len)) && retries) { - rc = cam_spi_wait(client, pg, addr_type); - msleep(client->spi_client->retry_delay); - retries--; - } + do { + rc = spi_write(spi, tx, len + header_len); + if (rc) { + if (retries == 0) { + break; + } else { + retries--; + cam_spi_wait(client, pg, addr_type); + msleep(client->spi_client->retry_delay); + } + } + } while (rc); + if (rc < 0) { CAM_ERR(CAM_SENSOR, "failed %d", rc); return rc; diff --git a/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c b/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c index 9a92698601..2f6ad6912b 100644 --- a/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c +++ b/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -2470,7 +2470,6 @@ int cam_sensor_util_power_down(struct cam_sensor_power_ctrl_t *ctrl, return -EINVAL; } - ps = NULL; CAM_DBG(CAM_SENSOR_UTIL, "seq_type %d", pd->seq_type); switch (pd->seq_type) { case SENSOR_MCLK: diff --git a/drivers/cam_utils/cam_soc_util.c b/drivers/cam_utils/cam_soc_util.c index d581841090..7bcbdf6f0a 100644 --- a/drivers/cam_utils/cam_soc_util.c +++ b/drivers/cam_utils/cam_soc_util.c @@ -843,7 +843,7 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_soc_util_clk_lvl_control_low, static int cam_soc_util_create_clk_lvl_debugfs(struct cam_hw_soc_info *soc_info) { int rc = 0; - struct dentry *dbgfileptr = NULL, *clkdirptr = NULL; + struct dentry *clkdirptr = NULL; if (!cam_debugfs_available()) return 0; @@ -864,23 +864,20 @@ static int cam_soc_util_create_clk_lvl_debugfs(struct cam_hw_soc_info *soc_info) } } - dbgfileptr = debugfs_create_dir(soc_info->dev_name, clkdirptr); - if (IS_ERR_OR_NULL(dbgfileptr)) { + soc_info->dentry = debugfs_create_dir(soc_info->dev_name, clkdirptr); + if (IS_ERR_OR_NULL(soc_info->dentry)) { CAM_ERR(CAM_UTIL, "DebugFS could not create directory for dev:%s!", soc_info->dev_name); rc = -ENOENT; goto end; } /* Store parent inode for cleanup in caller */ - soc_info->dentry = dbgfileptr; - - dbgfileptr = debugfs_create_file("clk_lvl_options", 0444, + debugfs_create_file("clk_lvl_options", 0444, soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_options); - dbgfileptr = debugfs_create_file("clk_lvl_control", 0644, + debugfs_create_file("clk_lvl_control", 0644, soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_control); - dbgfileptr = debugfs_create_file("clk_lvl_control_low", 0644, + debugfs_create_file("clk_lvl_control_low", 0644, soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_control_low); - rc = PTR_ERR_OR_ZERO(dbgfileptr); end: return rc; } @@ -2102,8 +2099,10 @@ static int cam_soc_util_get_gpio_info(struct cam_hw_soc_info *soc_info) CAM_DBG(CAM_UTIL, "gpio count %d", gpio_array_size); gpio_array = kcalloc(gpio_array_size, sizeof(uint16_t), GFP_KERNEL); - if (!gpio_array) - goto free_gpio_conf; + if (!gpio_array) { + rc = -ENOMEM; + goto err; + } for (i = 0; i < gpio_array_size; i++) { gpio_array[i] = of_get_gpio(of_node, i); @@ -2111,21 +2110,23 @@ static int cam_soc_util_get_gpio_info(struct cam_hw_soc_info *soc_info) } gconf = kzalloc(sizeof(*gconf), GFP_KERNEL); - if (!gconf) - return -ENOMEM; + if (!gconf) { + rc = -ENOMEM; + goto free_gpio_array; + } rc = cam_soc_util_get_dt_gpio_req_tbl(of_node, gconf, gpio_array, gpio_array_size); if (rc) { CAM_ERR(CAM_UTIL, "failed in msm_camera_get_dt_gpio_req_tbl"); - goto free_gpio_array; + goto free_gpio_conf; } gconf->cam_gpio_common_tbl = kcalloc(gpio_array_size, sizeof(struct gpio), GFP_KERNEL); if (!gconf->cam_gpio_common_tbl) { rc = -ENOMEM; - goto free_gpio_array; + goto free_gpio_conf; } for (i = 0; i < gpio_array_size; i++) @@ -2137,10 +2138,11 @@ static int cam_soc_util_get_gpio_info(struct cam_hw_soc_info *soc_info) return rc; -free_gpio_array: - kfree(gpio_array); free_gpio_conf: kfree(gconf); +free_gpio_array: + kfree(gpio_array); +err: soc_info->gpio_data = NULL; return rc; @@ -2215,7 +2217,6 @@ static int cam_soc_util_get_dt_regulator_info if (count != -EINVAL) { if (count <= 0) { CAM_ERR(CAM_UTIL, "no regulators found"); - count = 0; return -EINVAL; } @@ -2381,11 +2382,9 @@ int cam_soc_util_get_dt_properties(struct cam_hw_soc_info *soc_info) rc = of_property_read_string_index(of_node, "compatible", 0, (const char **)&soc_info->compatible); - if (rc) { + if (rc) CAM_DBG(CAM_UTIL, "No compatible string present for: %s", soc_info->dev_name); - rc = 0; - } soc_info->is_nrt_dev = false; if (of_property_read_bool(of_node, "nrt-device"))