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

Commit a606d18c authored by Harsh Shah's avatar Harsh Shah Committed by Karthik Anantha Ram
Browse files

msm: camera: crm: Clean up the handle struct on unlink



When unlink is called, struct handle needs to be cleaned up
completely. Only state is changed, but it still currently
holds the ops and priv pointers. The priv pointer can point to
link struct which gets freed in unlink. Hence need to clean
the priv pointer as well.

Change-Id: Icfe50aeec5edddea0605da037ff8099085b7ad0b
Signed-off-by: default avatarHarsh Shah <harshs@codeaurora.org>
parent 902b826c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -134,8 +134,8 @@ int cam_context_handle_crm_unlink(struct cam_context *ctx,
		rc = ctx->state_machine[ctx->state].crm_ops.unlink(
			ctx, unlink);
	} else {
		CAM_ERR(CAM_CORE, "No crm unlink in dev %d, state %d",
			ctx->dev_hdl, ctx->state);
		CAM_ERR(CAM_CORE, "No crm unlink in dev %d, name %s, state %d",
			ctx->dev_hdl, ctx->dev_name, ctx->state);
		rc = -EPROTO;
	}
	mutex_unlock(&ctx->ctx_mutex);
+15 −4
Original line number Diff line number Diff line
@@ -863,12 +863,14 @@ static void __cam_req_mgr_destroy_subdev(
 * @brief    : Cleans up the mem allocated while linking
 * @link     : pointer to link, mem associated with this link is freed
 *
 * @return   : returns if unlink for any device was success or failure
 */
static void __cam_req_mgr_destroy_link_info(struct cam_req_mgr_core_link *link)
static int __cam_req_mgr_destroy_link_info(struct cam_req_mgr_core_link *link)
{
	int32_t                                 i = 0;
	struct cam_req_mgr_connected_device    *dev;
	struct cam_req_mgr_core_dev_link_setup  link_data;
	int                                     rc = 0;

	link_data.link_enable = 0;
	link_data.link_hdl = link->link_hdl;
@@ -881,7 +883,11 @@ static void __cam_req_mgr_destroy_link_info(struct cam_req_mgr_core_link *link)
		if (dev != NULL) {
			link_data.dev_hdl = dev->dev_hdl;
			if (dev->ops && dev->ops->link_setup)
				dev->ops->link_setup(&link_data);
				rc = dev->ops->link_setup(&link_data);
				if (rc)
					CAM_ERR(CAM_CRM,
						"Unlink failed dev_hdl %d",
						dev->dev_hdl);
			dev->dev_hdl = 0;
			dev->parent = NULL;
			dev->ops = NULL;
@@ -896,6 +902,7 @@ static void __cam_req_mgr_destroy_link_info(struct cam_req_mgr_core_link *link)
	link->num_devs = 0;
	link->max_delay = 0;

	return rc;
}

/**
@@ -2024,8 +2031,12 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info)

	cam_req_mgr_workq_destroy(&link->workq);

	/* Cleanuprequest tables */
	__cam_req_mgr_destroy_link_info(link);
	/* Cleanup request tables and unlink devices */
	rc = __cam_req_mgr_destroy_link_info(link);
	if (rc) {
		CAM_ERR(CAM_CORE, "Unlink failed. Cannot proceed");
		return rc;
	}

	/* Free memory holding data of linked devs */
	__cam_req_mgr_destroy_subdev(link->l_dev);
+2 −0
Original line number Diff line number Diff line
@@ -317,6 +317,8 @@ static int cam_destroy_hdl(int32_t dev_hdl, int dev_hdl_type)
	}

	hdl_tbl->hdl[idx].state = HDL_FREE;
	hdl_tbl->hdl[idx].ops   = NULL;
	hdl_tbl->hdl[idx].priv  = NULL;
	clear_bit(idx, hdl_tbl->bitmap);
	spin_unlock_bh(&hdl_tbl_lock);