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

Commit ae32d2f5 authored by Shalini Krishnamoorthi's avatar Shalini Krishnamoorthi Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: Initialize pan_name array to 0 and handle error case



Initialize the pan_name array to 0 before trying to copy
data from mdss_mdp_panel array to prevent junk values
being wrongly parsed by strnstr function and return error
when panel name is '0', this would let us read the primary
panel interface from device tree.

CRs-Fixed: 1018618
Change-Id: Ibfea17610fe2be4ebf3588047d4eb1c7f0042096
Signed-off-by: default avatarShalini Krishnamoorthi <shakri@codeaurora.org>
parent 05a0c86d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2139,13 +2139,16 @@ static int mdss_mdp_get_pan_cfg(struct mdss_panel_cfg *pan_cfg)
	char *t = NULL;
	char pan_intf_str[MDSS_MAX_PANEL_LEN];
	int rc, i, panel_len;
	char pan_name[MDSS_MAX_PANEL_LEN];
	char pan_name[MDSS_MAX_PANEL_LEN] = {'\0'};

	if (!pan_cfg)
		return -EINVAL;

	if (mdss_mdp_panel[0] == '0') {
		pr_debug("panel name is not set\n");
		pan_cfg->lk_cfg = false;
		pan_cfg->pan_intf = MDSS_PANEL_INTF_INVALID;
		return -EINVAL;
	} else if (mdss_mdp_panel[0] == '1') {
		pan_cfg->lk_cfg = true;
	} else {
@@ -2155,7 +2158,7 @@ static int mdss_mdp_get_pan_cfg(struct mdss_panel_cfg *pan_cfg)
		return -EINVAL;
	}

	/* skip lk cfg and delimiter; ex: "0:" */
	/* skip lk cfg and delimiter; ex: "1:" */
	strlcpy(pan_name, &mdss_mdp_panel[2], MDSS_MAX_PANEL_LEN);
	t = strnstr(pan_name, ":", MDSS_MAX_PANEL_LEN);
	if (!t) {