Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccfbd11d authored by Vishalsingh Hajeri's avatar Vishalsingh Hajeri
Browse files

Revert "msm: camera: icp: Freeing memory in workqueue"



This reverts Ieae412f21097a304c390163bab2116623a252ffc
as it may lead to memory leak.

Change-Id: I6bd5fb6aaaa0e45c74718df21bd96d6acfedb2bc
Signed-off-by: default avatarVishalsingh Hajeri <vhajeri@codeaurora.org>
parent c814c642
Loading
Loading
Loading
Loading
+9 −45
Original line number Diff line number Diff line
@@ -1314,32 +1314,6 @@ static int cam_icp_hw_mgr_create_debugfs_entry(void)
	return rc;
}

static int cam_icp_mgr_process_cmd_and_free_mem(void *priv, void *data)
{
	int rc;
	struct hfi_cmd_work_data *task_data = NULL;
	struct cam_icp_hw_mgr *hw_mgr;

	if (!data || !priv) {
		CAM_ERR(CAM_ICP, "Invalid params%pK %pK", data, priv);
		return -EINVAL;
	}

	hw_mgr = priv;
	task_data = (struct hfi_cmd_work_data *)data;

	if (!task_data->data) {
		CAM_ERR(CAM_ICP, "Invalid data");
		return -EINVAL;
	}

	rc = hfi_write_cmd(task_data->data);

	kfree(task_data->data);
	task_data->data = NULL;
	return rc;
}

static int cam_icp_mgr_process_cmd(void *priv, void *data)
{
	int rc;
@@ -2214,14 +2188,13 @@ static int cam_icp_mgr_abort_handle(
	task_data->data = (void *)abort_cmd;
	task_data->request_id = 0;
	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
	task->process_cb = cam_icp_mgr_process_cmd_and_free_mem;
	task->process_cb = cam_icp_mgr_process_cmd;
	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
		CRM_TASK_PRIORITY_0);
	if (rc) {
		kfree(abort_cmd);
		return rc;
	}
	CAM_DBG(CAM_ICP, "payload data = %pK", task_data->data);
	CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
		ctx_data->fw_handle, ctx_data);
	rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
@@ -2278,14 +2251,13 @@ static int cam_icp_mgr_destroy_handle(
	task_data->data = (void *)destroy_cmd;
	task_data->request_id = 0;
	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
	task->process_cb = cam_icp_mgr_process_cmd_and_free_mem;
	task->process_cb = cam_icp_mgr_process_cmd;
	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
		CRM_TASK_PRIORITY_0);
	if (rc) {
		kfree(destroy_cmd);
		return rc;
	}
	CAM_DBG(CAM_ICP, "payload data = %pK", task_data->data);
	CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
		ctx_data->fw_handle, ctx_data);
	rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
@@ -3560,7 +3532,7 @@ static int cam_icp_mgr_create_handle(uint32_t dev_type,

static int cam_icp_mgr_send_ping(struct cam_icp_hw_ctx_data *ctx_data)
{
	struct hfi_cmd_ping_pkt *ping_pkt;
	struct hfi_cmd_ping_pkt ping_pkt;
	struct hfi_cmd_work_data *task_data;
	unsigned long rem_jiffies;
	int timeout = 5000;
@@ -3573,28 +3545,20 @@ static int cam_icp_mgr_send_ping(struct cam_icp_hw_ctx_data *ctx_data)
		return -ENOMEM;
	}

	ping_pkt = kzalloc(sizeof(struct hfi_cmd_ping_pkt), GFP_KERNEL);
	if (!ping_pkt) {
		rc = -ENOMEM;
		return rc;
	}
	ping_pkt->size = sizeof(struct hfi_cmd_ping_pkt);
	ping_pkt->pkt_type = HFI_CMD_SYS_PING;
	ping_pkt->user_data = (uint64_t)ctx_data;
	ping_pkt.size = sizeof(struct hfi_cmd_ping_pkt);
	ping_pkt.pkt_type = HFI_CMD_SYS_PING;
	ping_pkt.user_data = (uint64_t)ctx_data;
	init_completion(&ctx_data->wait_complete);
	task_data = (struct hfi_cmd_work_data *)task->payload;
	task_data->data = (void *)ping_pkt;
	task_data->data = (void *)&ping_pkt;
	task_data->request_id = 0;
	task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
	task->process_cb = cam_icp_mgr_process_cmd_and_free_mem;
	task->process_cb = cam_icp_mgr_process_cmd;

	rc = cam_req_mgr_workq_enqueue_task(task, &icp_hw_mgr,
		CRM_TASK_PRIORITY_0);
	if (rc) {
		kfree(ping_pkt);
	if (rc)
		return rc;
	}
	CAM_DBG(CAM_ICP, "payload data = %pK", task_data->data);

	rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
			msecs_to_jiffies((timeout)));