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

Commit 9ca8558d authored by Shashank Babu Chinta Venkata's avatar Shashank Babu Chinta Venkata Committed by Gerrit - the friendly Code Review server
Browse files

drm/msm/dsi-staging: add accurate index to prevent out of bounds errors



This change adds accurate index for link clocks to prevent
out of bounds access while doing a container_of.

Change-Id: I6f31d20c7af15dc014234a2356af022f2f75d036
Signed-off-by: default avatarShashank Babu Chinta Venkata <sbchin@codeaurora.org>
parent 2f860dad
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -285,13 +285,17 @@ int dsi_core_clk_stop(struct dsi_core_clks *c_clks)
	return rc;
}

static int dsi_link_clk_set_rate(struct dsi_link_clks *l_clks)
static int dsi_link_clk_set_rate(struct dsi_link_clks *l_clks, int index)
{
	int rc = 0;
	struct dsi_clk_mngr *mngr;

	mngr = container_of(l_clks, struct dsi_clk_mngr, link_clks[0]);
	if (index >= MAX_DSI_CTRL) {
		pr_err("Invalid DSI ctrl index\n");
		return -EINVAL;
	}

	mngr = container_of(l_clks, struct dsi_clk_mngr, link_clks[index]);
	if (mngr->is_cont_splash_enabled)
		return 0;
	/*
@@ -443,11 +447,16 @@ static void dsi_link_clk_disable(struct dsi_link_clks *l_clks)
/**
 * dsi_link_clk_start() - enable dsi link clocks
 */
int dsi_link_clk_start(struct dsi_link_clks *clks)
static int dsi_link_clk_start(struct dsi_link_clks *clks, int index)
{
	int rc = 0;

	rc = dsi_link_clk_set_rate(clks);
	if (index >= MAX_DSI_CTRL) {
		pr_err("Invalid DSI ctrl index\n");
		return -EINVAL;
	}

	rc = dsi_link_clk_set_rate(clks, index);
	if (rc) {
		pr_err("failed to set clk rates, rc = %d\n", rc);
		goto error;
@@ -561,7 +570,7 @@ static int dsi_display_link_clk_enable(struct dsi_link_clks *clks,

	m_clks = &clks[master_ndx];

	rc = dsi_link_clk_start(m_clks);
	rc = dsi_link_clk_start(m_clks, master_ndx);
	if (rc) {
		pr_err("failed to turn on master clocks, rc=%d\n", rc);
		goto error;
@@ -573,7 +582,7 @@ static int dsi_display_link_clk_enable(struct dsi_link_clks *clks,
		if (!clk || (clk == m_clks))
			continue;

		rc = dsi_link_clk_start(clk);
		rc = dsi_link_clk_start(clk, i);
		if (rc) {
			pr_err("failed to turn on clocks, rc=%d\n", rc);
			goto error_disable_master;