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

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

Merge "msm: camera: core: Check context state prior to handle release" into dev/msm-4.14-camx

parents e7a76d4d 70a5d5bf
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -286,20 +286,30 @@ static int __cam_node_handle_release_dev(struct cam_node *node,
		return -EINVAL;
	}

	if (ctx->state > CAM_CTX_UNINIT && ctx->state < CAM_CTX_STATE_MAX) {
		rc = cam_context_handle_release_dev(ctx, release);
		if (rc)
		CAM_ERR(CAM_CORE, "context release failed node %s", node->name);
			CAM_ERR(CAM_CORE, "context release failed for node %s",
				node->name);
	} else {
		CAM_WARN(CAM_CORE,
			"node %s context id %u state %d invalid to release hdl",
			node->name, ctx->ctx_id, ctx->state);
		goto destroy_dev_hdl;
	}

	cam_context_putref(ctx);

destroy_dev_hdl:
	rc = cam_destroy_device_hdl(release->dev_handle);
	if (rc)
		CAM_ERR(CAM_CORE, "destroy device handle is failed node %s",
		CAM_ERR(CAM_CORE, "destroy device hdl failed for node %s",
			node->name);

	CAM_DBG(CAM_CORE, "[%s] Release ctx_id=%d, refcount=%d",
		node->name, ctx->ctx_id,
		atomic_read(&(ctx->refcount.refcount.refs)));

	cam_context_putref(ctx);
	return rc;
}