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

Commit 99eaacc2 authored by Shravya Samala's avatar Shravya Samala Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: utils: Rate limit error log in case of invalid handles



Rate limit errors logs in case of incoming invalid handles
from userspace.

CRs-Fixed: 28077125
Change-Id: I3f8765be2f07f869149b9315ab38b7d02ae71a58
Signed-off-by: default avatarShravya Samala <shravyas@codeaurora.org>
parent 2dc88593
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -535,8 +535,8 @@ int32_t cam_context_acquire_dev_to_hw(struct cam_context *ctx,
		cmd->resource_hdl);
		cmd->resource_hdl);


	if (cmd->num_resources > CAM_CTX_RES_MAX) {
	if (cmd->num_resources > CAM_CTX_RES_MAX) {
		CAM_ERR(CAM_CTXT, "[%s][%d] resource limit exceeded",
		CAM_ERR(CAM_CTXT, "[%s][%d] resource[%d] limit exceeded",
			ctx->dev_name, ctx->ctx_id);
			ctx->dev_name, ctx->ctx_id, cmd->num_resources);
		rc = -ENOMEM;
		rc = -ENOMEM;
		goto end;
		goto end;
	}
	}
+18 −9
Original line number Original line Diff line number Diff line
@@ -346,31 +346,36 @@ static int __cam_node_handle_flush_dev(struct cam_node *node,
		return -EINVAL;
		return -EINVAL;


	if (flush->dev_handle <= 0) {
	if (flush->dev_handle <= 0) {
		CAM_ERR(CAM_CORE, "Invalid device handle for context");
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Invalid device handle for context");
		return -EINVAL;
		return -EINVAL;
	}
	}


	if (flush->session_handle <= 0) {
	if (flush->session_handle <= 0) {
		CAM_ERR(CAM_CORE, "Invalid session handle for context");
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Invalid session handle for context");
		return -EINVAL;
		return -EINVAL;
	}
	}


	ctx = (struct cam_context *)cam_get_device_priv(flush->dev_handle);
	ctx = (struct cam_context *)cam_get_device_priv(flush->dev_handle);
	if (!ctx) {
	if (!ctx) {
		CAM_ERR(CAM_CORE, "Can not get context for handle %d",
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Can not get context for handle %d",
			flush->dev_handle);
			flush->dev_handle);
		return -EINVAL;
		return -EINVAL;
	}
	}


	if (strcmp(node->name, ctx->dev_name)) {
	if (strcmp(node->name, ctx->dev_name)) {
		CAM_ERR(CAM_CORE, "node name %s dev name:%s not matching",
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"node name %s dev name:%s not matching",
			node->name, ctx->dev_name);
			node->name, ctx->dev_name);
		return -EINVAL;
		return -EINVAL;
	}
	}


	rc = cam_context_handle_flush_dev(ctx, flush);
	rc = cam_context_handle_flush_dev(ctx, flush);
	if (rc)
	if (rc)
		CAM_ERR(CAM_CORE, "Flush failure for node %s", node->name);
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Flush failure for node %s", node->name);


	return rc;
	return rc;
}
}
@@ -446,25 +451,29 @@ static int __cam_node_handle_dump_dev(struct cam_node *node,
		return -EINVAL;
		return -EINVAL;


	if (dump->dev_handle <= 0) {
	if (dump->dev_handle <= 0) {
		CAM_ERR(CAM_CORE, "Invalid device handle for context");
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Invalid device handle for context");
		return -EINVAL;
		return -EINVAL;
	}
	}


	if (dump->session_handle <= 0) {
	if (dump->session_handle <= 0) {
		CAM_ERR(CAM_CORE, "Invalid session handle for context");
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Invalid session handle for context");
		return -EINVAL;
		return -EINVAL;
	}
	}


	ctx = (struct cam_context *)cam_get_device_priv(dump->dev_handle);
	ctx = (struct cam_context *)cam_get_device_priv(dump->dev_handle);
	if (!ctx) {
	if (!ctx) {
		CAM_ERR(CAM_CORE, "Can not get context for handle %d",
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Can not get context for handle %d",
			dump->dev_handle);
			dump->dev_handle);
		return -EINVAL;
		return -EINVAL;
	}
	}


	rc = cam_context_handle_dump_dev(ctx, dump);
	rc = cam_context_handle_dump_dev(ctx, dump);
	if (rc)
	if (rc)
		CAM_ERR(CAM_CORE, "Dump failure for node %s", node->name);
		CAM_ERR_RATE_LIMIT(CAM_CORE,
			"Dump failure for node %s", node->name);


	return rc;
	return rc;
}
}
+10 −8
Original line number Original line Diff line number Diff line
@@ -223,23 +223,25 @@ void *cam_get_device_priv(int32_t dev_hdl)


	idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl);
	idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl);
	if (idx >= CAM_REQ_MGR_MAX_HANDLES_V2) {
	if (idx >= CAM_REQ_MGR_MAX_HANDLES_V2) {
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx");
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx:%d", idx);
		goto device_priv_fail;
		goto device_priv_fail;
	}
	}


	if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) {
	if (hdl_tbl->hdl[idx].hdl_value != dev_hdl) {
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state");
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid hdl [%d] [%d]",
			dev_hdl, hdl_tbl->hdl[idx].hdl_value);
		goto device_priv_fail;
		goto device_priv_fail;
	}
	}


	type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl);
	if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) {
	if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) {
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state:%d",
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid type");
			hdl_tbl->hdl[idx].state);
		goto device_priv_fail;
		goto device_priv_fail;
	}
	}


	if (hdl_tbl->hdl[idx].hdl_value != dev_hdl) {
	type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl);
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid hdl");
	if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) {
		CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid type:%d", type);
		goto device_priv_fail;
		goto device_priv_fail;
	}
	}