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

Commit d1a9fffc authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: Memory leak fix across camera drivers" into dev/msm-4.9-camx

parents c3535e96 270a5870
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1092,6 +1092,7 @@ int cam_fd_hw_release(void *hw_priv, void *hw_release_args, uint32_t arg_size)
		CAM_ERR(CAM_FD, "Release cdm handle failed, handle=0x%x, rc=%d",
			ctx_hw_private->cdm_handle, rc);

	kfree(ctx_hw_private->cdm_cmd);
	kfree(ctx_hw_private);
	release_args->ctx_hw_private = NULL;

+10 −10
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -207,37 +207,38 @@ static int32_t cam_a5_download_fw(void *device_priv)

	if (!core_info->fw_elf) {
		CAM_ERR(CAM_ICP, "Invalid elf size");
		return -EINVAL;
		rc = -EINVAL;
		goto fw_download_failed;
	}

	fw_start = core_info->fw_elf->data;
	rc = cam_icp_validate_fw(fw_start);
	if (rc) {
		CAM_ERR(CAM_ICP, "fw elf validation failed");
		return -EINVAL;
		goto fw_download_failed;
	}

	rc = cam_icp_get_fw_size(fw_start, &fw_size);
	if (rc) {
		CAM_ERR(CAM_ICP, "unable to get fw size");
		return rc;
		goto fw_download_failed;
	}

	if (core_info->fw_buf_len < fw_size) {
		CAM_ERR(CAM_ICP, "mismatch in fw size: %u %llu",
			fw_size, core_info->fw_buf_len);
		goto fw_alloc_failed;
		rc = -EINVAL;
		goto fw_download_failed;
	}

	rc = cam_icp_program_fw(fw_start, core_info);
	if (rc) {
		CAM_ERR(CAM_ICP, "fw program is failed");
		goto fw_program_failed;
		goto fw_download_failed;
	}

	return 0;
fw_program_failed:
fw_alloc_failed:
fw_download_failed:
	release_firmware(core_info->fw_elf);
	return rc;
}

@@ -387,7 +388,6 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type,
	switch (cmd_type) {
	case CAM_ICP_A5_CMD_FW_DOWNLOAD:
		rc = cam_a5_download_fw(device_priv);

		break;
	case CAM_ICP_A5_CMD_SET_FW_BUF: {
		struct cam_icp_a5_set_fw_buf_info *fw_buf_info = cmd_args;
+7 −14
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -924,6 +924,7 @@ static int cam_jpeg_mgr_release_hw(void *hw_mgr_priv, void *release_hw_args)
	if (hw_mgr->cdm_info[dev_type][0].ref_cnt == 0) {
		mutex_unlock(&hw_mgr->hw_mgr_mutex);
		CAM_ERR(CAM_JPEG, "Error Unbalanced deinit");
		kfree(ctx_data->cdm_cmd);
		return -EFAULT;
	}

@@ -943,9 +944,12 @@ static int cam_jpeg_mgr_release_hw(void *hw_mgr_priv, void *release_hw_args)
	rc = cam_jpeg_mgr_release_ctx(hw_mgr, ctx_data);
	if (rc) {
		mutex_unlock(&hw_mgr->hw_mgr_mutex);
		CAM_ERR(CAM_JPEG, "JPEG release ctx failed");
		kfree(ctx_data->cdm_cmd);
		return -EINVAL;
	}

	kfree(ctx_data->cdm_cmd);
	CAM_DBG(CAM_JPEG, "handle %llu", ctx_data);

	return rc;
@@ -999,7 +1003,7 @@ static int cam_jpeg_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
			sizeof(struct cam_cdm_bl_cmd))), GFP_KERNEL);
	if (!ctx_data->cdm_cmd) {
		rc = -ENOMEM;
		goto acq_cdm_hdl_failed;
		goto jpeg_release_ctx;
	}

	mutex_lock(&ctx_data->ctx_mutex);
@@ -1046,20 +1050,8 @@ static int cam_jpeg_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
		hw_mgr->cdm_info[dev_type][0].ref_cnt++;
	}

	ctx_data->cdm_cmd_chbase =
		kzalloc(((sizeof(struct cam_cdm_bl_request)) +
			(2 * sizeof(struct cam_cdm_bl_cmd))), GFP_KERNEL);
	if (!ctx_data->cdm_cmd_chbase) {
		rc = -ENOMEM;
		goto start_cdm_hdl_failed;
	}
	size = hw_mgr->cdm_info[dev_type][0].
		cdm_ops->cdm_required_size_changebase();
	ctx_data->cmd_chbase_buf_addr = kzalloc(size*4, GFP_KERNEL);
	if (!ctx_data->cdm_cmd_chbase) {
		rc = -ENOMEM;
		goto start_cdm_hdl_failed;
	}

	if (hw_mgr->cdm_info[dev_type][0].ref_cnt == 1)
		if (cam_cdm_stream_on(
@@ -1101,6 +1093,7 @@ static int cam_jpeg_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
	hw_mgr->cdm_info[dev_type][0].ref_cnt--;
acq_cdm_hdl_failed:
	kfree(ctx_data->cdm_cmd);
jpeg_release_ctx:
	cam_jpeg_mgr_release_ctx(hw_mgr, ctx_data);
	mutex_unlock(&hw_mgr->hw_mgr_mutex);

+1 −5
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -95,8 +95,6 @@ struct cam_jpeg_hw_cfg_req {
 * @in_use: Flag for context usage
 * @wait_complete: Completion info
 * @cdm_cmd: Cdm cmd submitted for that context.
 * @cdm_cmd_chbase: Change base cdm command from context
 * @cmd_chbase_buf_addr : Change base cmd buf address
 */
struct cam_jpeg_hw_ctx_data {
	void *context_priv;
@@ -106,8 +104,6 @@ struct cam_jpeg_hw_ctx_data {
	bool in_use;
	struct completion wait_complete;
	struct cam_cdm_bl_request *cdm_cmd;
	struct cam_cdm_bl_request *cdm_cmd_chbase;
	uint32_t *cmd_chbase_buf_addr;
};

/**