Selaa lähdekoodia

msm: camera: common: Fixing memory leak issues

This change removes some dead code and fixes memory leak
issues and mismatched labels.

CRs-Fixed: 3394193
Change-Id: Ieb6f0d56cddc58be4caea6f0aece63a793a08c07
Signed-off-by: Atiya Kailany <[email protected]>
Atiya Kailany 2 vuotta sitten
vanhempi
sitoutus
2bb45ffd4c

+ 1 - 2
drivers/cam_cpas/cam_cpas_hw.c

@@ -3533,7 +3533,7 @@ static int cam_cpas_dump_state_monitor_array_info(
 	struct cam_cpas_private_soc *soc_private =
 		(struct cam_cpas_private_soc *) cpas_hw->soc_info.soc_private;
 	struct cam_cpas_monitor         *entry;
-	uint32_t monitor_idx, camnoc_lvl_regs_num;
+	uint32_t monitor_idx;
 
 	state_head = atomic64_read(&cpas_core->monitor_head);
 	if (state_head == -1) {
@@ -3581,7 +3581,6 @@ static int cam_cpas_dump_state_monitor_array_info(
 
 		for (camnoc_idx = 0; camnoc_idx < cpas_core->num_valid_camnoc; camnoc_idx++) {
 			min_len += sizeof(uint64_t);
-			camnoc_lvl_regs_num = entry->num_camnoc_lvl_regs[camnoc_idx];
 			for (j = 0; j < entry->num_camnoc_lvl_regs[camnoc_idx]; j++)
 				min_len += sizeof(struct cam_common_hw_dump_header);
 		}

+ 1 - 0
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -7590,6 +7590,7 @@ static int cam_icp_mgr_alloc_devs(struct device_node *np, struct cam_icp_hw_mgr
 			hw_mgr->hw_mgr_name, icp_hw_type);
 		rc = -EINVAL;
 		kfree(devices);
+		kfree(alloc_devices);
 		return rc;
 	}
 

+ 0 - 4
drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c

@@ -88,10 +88,8 @@ int cam_isp_add_change_base(
 	struct cam_isp_hw_mgr_res       *hw_mgr_res;
 	struct cam_isp_resource_node    *res;
 	struct cam_isp_hw_get_cmd_update get_base;
-	struct cam_hw_update_entry      *hw_entry;
 	uint32_t                         num_ent, i;
 
-	hw_entry = prepare->hw_update_entries;
 	num_ent = prepare->num_hw_update_entries;
 
 	/* Max one hw entries required for each base */
@@ -1117,7 +1115,6 @@ int cam_isp_add_io_buffers(struct cam_isp_io_buf_info   *io_info)
 	uint32_t                            i;
 	uint32_t                            curr_used_bytes = 0;
 	uint32_t                            bytes_updated = 0;
-	uint32_t                            curr_offset = 0;
 	struct cam_isp_resource_node       *res = NULL;
 	int                                 ctxt_id = 0;
 	uint8_t                             num_ports[CAM_ISP_MULTI_CTXT_MAX] = {0};
@@ -1129,7 +1126,6 @@ int cam_isp_add_io_buffers(struct cam_isp_io_buf_info   *io_info)
 			&io_info->prepare->packet->payload +
 			io_info->prepare->packet->io_configs_offset);
 	curr_used_bytes = io_info->kmd_buf_info->used_bytes;
-	curr_offset = io_info->kmd_buf_info->offset;
 
 	/* Max one hw entries required for each base */
 	if (io_info->prepare->num_hw_update_entries + 1 >=

+ 3 - 0
drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c

@@ -2011,6 +2011,9 @@ iodump:
 			hw_mgr->devices[dev_type][CAM_JPEG_MEM_BASE_INDEX]->hw_priv,
 			CAM_JPEG_CMD_DUMP_DEBUG_REGS,
 			NULL, 0);
+		if (rc)
+			CAM_ERR(CAM_JPEG, "Invalid process_cmd ops");
+
 	} else {
 		CAM_ERR(CAM_JPEG, "Invalid dev_type %d", dev_type);
 	}

+ 0 - 3
drivers/cam_req_mgr/cam_mem_mgr.c

@@ -1799,7 +1799,6 @@ static void cam_mem_util_unmap(struct kref *kref)
 
 void cam_mem_put_cpu_buf(int32_t buf_handle)
 {
-	int rc = 0;
 	int idx;
 
 	if (!buf_handle) {
@@ -1815,14 +1814,12 @@ void cam_mem_put_cpu_buf(int32_t buf_handle)
 
 	if (!tbl.bufq[idx].active) {
 		CAM_ERR(CAM_MEM, "idx: %d not active", idx);
-		rc = -EPERM;
 		return;
 	}
 
 	if (buf_handle != tbl.bufq[idx].buf_handle) {
 		CAM_ERR(CAM_MEM, "idx: %d Invalid buf handle %d",
 				idx, buf_handle);
-		rc = -EINVAL;
 		return;
 	}
 

+ 1 - 1
drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c

@@ -690,7 +690,7 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
 			goto end;
 		}
 		break;
-	case CAM_PKT_NOP_OPCODE:
+	case CAM_ACTUATOR_PACKET_NOP_OPCODE:
 		if (a_ctrl->cam_act_state < CAM_ACTUATOR_CONFIG) {
 			CAM_WARN(CAM_ACTUATOR,
 				"Received NOP packets in invalid state: %d",

+ 1 - 1
drivers/cam_sensor_module/cam_sensor_module_debug.c

@@ -119,7 +119,7 @@ static int cam_sensor_module_parse_line(const char *p_line,
 	} else if (p_line[0] == 'w'  || p_line[0] == 'W') {
 		*is_read = false;
 
-		rc = sscanf(p_line+2, "%x,%x,%d,%d,%d,%d,%d",
+		rc = sscanf(p_line+2, "%x,%x,%u,%d,%d,%d,%d",
 			&reg_array->reg_addr,  &reg_array->reg_data, &reg_array->delay,
 			&reg_list->addr_type, &reg_list->data_type,
 			&device_type, &instance_number);

+ 4 - 1
drivers/cam_sensor_module/cam_tpg/cam_tpg_core.c

@@ -522,8 +522,10 @@ static int cam_tpg_cmd_buf_parse(
 
 		rc = cam_tpg_validate_cmd_descriptor(cmd_desc,
 				&cmd_type, &cmd_addr);
-		if (rc < 0)
+		if (rc < 0) {
+			kfree(req);
 			goto end;
+		}
 
 		cmd_header = (struct tpg_command_header_t *)cmd_addr;
 
@@ -578,6 +580,7 @@ end:
 free_request:
 	/* free the request and return the failure */
 	tpg_hw_free_request(&tpg_dev->tpg_hw, req);
+	kfree(req);
 	return rc;
 }
 

+ 1 - 3
drivers/cam_utils/cam_debug_util.c

@@ -284,15 +284,13 @@ void cam_print_log(int type, int module, int tag, const char *func,
 	int line, const char *fmt, ...)
 {
 	char buf[CAM_LOG_BUF_LEN] = {0,};
-	int len = 0;
-
 	va_list args;
 
 	if (!type)
 		return;
 
 	va_start(args, fmt);
-	len = vscnprintf(buf, CAM_LOG_BUF_LEN, fmt, args);
+	vscnprintf(buf, CAM_LOG_BUF_LEN, fmt, args);
 	__cam_print_log(type, __CAM_LOG_FMT,
 		CAM_LOG_TAG_NAME(tag), CAM_DBG_MOD_NAME(module), func,
 		line, buf);

+ 2 - 1
include/uapi/camera/media/cam_sensor.h

@@ -67,7 +67,8 @@ enum cam_actuator_packet_opcodes {
 	CAM_ACTUATOR_PACKET_OPCODE_INIT,
 	CAM_ACTUATOR_PACKET_AUTO_MOVE_LENS,
 	CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS,
-	CAM_ACTUATOR_PACKET_OPCODE_READ
+	CAM_ACTUATOR_PACKET_OPCODE_READ,
+	CAM_ACTUATOR_PACKET_NOP_OPCODE = 127
 };
 
 enum cam_eeprom_packet_opcodes {