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

Commit f3ec1743 authored by Sultanxda's avatar Sultanxda Committed by TARKZiM
Browse files

msm: mdss: Don't cache the address of a stack variable in timings init



When the panel timings are parsed, a stack-allocated variable is used to
store the parsed data; however, this creates two problems. The first
problem is that this creates a memory leak since a kstrdup() address is
stored into the stack-allocated variable at the end of the
mdss_dsi_panel_timing_from_dt() function. The second problem this creates
is that the address of the stack-allocated variable is stored into the
current_timing struct member (inside mdss_dsi_panel_timing_switch()) for
future use in the driver.

Since the data that current_timing points to is expected to persist long
after init, allocate memory for the timing settings to fix the issues.

Change-Id: I2bbc957b229a010c1b5701f2e40e42e65cd88b2d
Signed-off-by: default avatarSultanxda <sultanxda@gmail.com>
parent 4575a30c
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1629,19 +1629,24 @@ static int mdss_dsi_panel_parse_display_timings(struct device_node *np,

	timings_np = of_get_child_by_name(np, "qcom,mdss-dsi-display-timings");
	if (!timings_np) {
		struct dsi_panel_timing pt;
		memset(&pt, 0, sizeof(struct dsi_panel_timing));
		struct dsi_panel_timing *pt;

		pt = kzalloc(sizeof(*pt), GFP_KERNEL);
		if (!pt)
			return -ENOMEM;

		/*
		 * display timings node is not available, fallback to reading
		 * timings directly from root node instead
		 */
		pr_debug("reading display-timings from panel node\n");
		rc = mdss_dsi_panel_timing_from_dt(np, &pt);
		rc = mdss_dsi_panel_timing_from_dt(np, pt);
		if (!rc) {
			mdss_dsi_panel_config_res_properties(np,
				panel_data->panel_info.sim_panel_mode, &pt);
			rc = mdss_dsi_panel_timing_switch(ctrl, &pt.timing);
				panel_data->panel_info.sim_panel_mode, pt);
			rc = mdss_dsi_panel_timing_switch(ctrl, &pt->timing);
		} else {
			kfree(pt);
		}
		return rc;
	}