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

Commit 227829fd authored by Ping Li's avatar Ping Li Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: Fix bugs in mdss code



This patch fixes bugs in mdss code, including uninitialized variables,
potential integer overflow, unnecessary condition check, incorrect use
of logical and bitwise operator and unreleased memory in error case.

Change-Id: Id579edc5e8f78aa8c295f1fccc88230ca00202ad
Signed-off-by: default avatarPing Li <pingli@codeaurora.org>
parent f265ab81
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1079,6 +1079,7 @@ int mdss_iommu_init(struct mdss_data_type *mdata)
		layout.partitions = iomap->partitions;
		layout.npartitions = iomap->npartitions;
		layout.is_secure = (i == MDSS_IOMMU_DOMAIN_SECURE);
		layout.domain_flags = 0;

		iomap->domain_idx = msm_register_domain(&layout);
		if (IS_ERR_VALUE(iomap->domain_idx))
+1 −1
Original line number Diff line number Diff line
@@ -1043,7 +1043,7 @@ int mdss_mdp_perf_bw_check_pipe(struct mdss_mdp_perf_params *perf,
		return 0;

	vbp_fac = mdss_mdp_get_vbp_factor_max(ctl);
	prefill_bw = perf->prefill_bytes * vbp_fac;
	prefill_bw = (u64)(perf->prefill_bytes) * (vbp_fac);
	pipe_bw = max(prefill_bw, perf->bw_overlap);
	pr_debug("prefill=%llu, vbp_fac=%u, overlap=%llu\n",
			prefill_bw, vbp_fac, perf->bw_overlap);
+8 −10
Original line number Diff line number Diff line
@@ -2226,12 +2226,10 @@ static int pp_ad_calc_bl(struct msm_fb_data_type *mfd, int bl_in, int *bl_out,
		return -EPERM;
	}

	if (!ad->bl_mfd || !ad->bl_mfd->panel_info ||
		!ad->bl_att_lut) {
		pr_err("Invalid ad info: bl_mfd = 0x%p, ad->bl_mfd->panel_info = 0x%p, bl_att_lut = 0x%p\n",
	if (!ad->bl_mfd || !ad->bl_mfd->panel_info) {
		pr_err("Invalid ad info: bl_mfd = 0x%p, ad->bl_mfd->panel_info = 0x%p\n",
			ad->bl_mfd,
			(!ad->bl_mfd) ? NULL : ad->bl_mfd->panel_info,
			ad->bl_att_lut);
			(!ad->bl_mfd) ? NULL : ad->bl_mfd->panel_info);
		mutex_unlock(&ad->lock);
		return -EINVAL;
	}
@@ -4596,7 +4594,7 @@ int mdss_mdp_ad_input(struct msm_fb_data_type *mfd,
	mutex_lock(&ad->lock);
	if ((!PP_AD_STATE_IS_INITCFG(ad->state) &&
			!PP_AD_STS_IS_DIRTY(ad->sts)) &&
			!input->mode == MDSS_AD_MODE_CALIB) {
			(input->mode != MDSS_AD_MODE_CALIB)) {
		pr_warn("AD not initialized or configured.\n");
		ret = -EPERM;
		goto error;
@@ -5014,10 +5012,10 @@ static int mdss_mdp_ad_setup(struct msm_fb_data_type *mfd)
			/* Clear state and regs when going to off state*/
			ad->sts = 0;
			ad->sts |= PP_AD_STS_DIRTY_VSYNC;
			ad->state &= !PP_AD_STATE_INIT;
			ad->state &= !PP_AD_STATE_CFG;
			ad->state &= !PP_AD_STATE_DATA;
			ad->state &= !PP_AD_STATE_BL_LIN;
			ad->state &= ~PP_AD_STATE_INIT;
			ad->state &= ~PP_AD_STATE_CFG;
			ad->state &= ~PP_AD_STATE_DATA;
			ad->state &= ~PP_AD_STATE_BL_LIN;
			ad->ad_data = 0;
			ad->ad_data_mode = 0;
			ad->last_bl = 0;
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -93,6 +93,7 @@ int mdss_panel_debugfs_setup(struct mdss_panel_info *panel_info, struct dentry
	if (IS_ERR_OR_NULL(debugfs_info->root)) {
		pr_err("Debugfs create dir failed with error: %ld\n",
					PTR_ERR(debugfs_info->root));
		kfree(debugfs_info);
		return -ENODEV;
	}