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

Commit 38d4aa7f authored by E V Ravi's avatar E V Ravi Committed by Gerrit - the friendly Code Review server
Browse files

msm: For camera driver Adding null checks to uninitialize



Unintializing if null check is true before clk_info used
and assigning to NULL if dt check fails.

Change-Id: Ide5b7fc51a9fcb0d22333a3063f21963c0747319
Signed-off-by: default avatarE V Ravi <evenka@codeaurora.org>
parent 147ed3c7
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2019, 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
@@ -58,18 +58,21 @@ static int msm_camera_get_clk_info_internal(struct device *dev,
	cnt = of_property_count_strings(of_node, "clock-names");
	if (cnt <= 0) {
		pr_err("err: No clocks found in DT=%zu\n", cnt);
		*clk_info = NULL;
		return -EINVAL;
	}

	tmp = of_property_count_u32_elems(of_node, "qcom,clock-rates");
	if (tmp <= 0) {
		pr_err("err: No clk rates device tree, count=%zu", tmp);
		*clk_info = NULL;
		return -EINVAL;
	}

	if (cnt != tmp) {
		pr_err("err: clk name/rates mismatch, strings=%zu, rates=%zu\n",
			cnt, tmp);
		*clk_info = NULL;
		return -EINVAL;
	}

@@ -79,11 +82,13 @@ static int msm_camera_get_clk_info_internal(struct device *dev,
		if (tmp <= 0) {
			pr_err("err: control strings not found in DT count=%zu",
				tmp);
			*clk_info = NULL;
			return -EINVAL;
		}
		if (cnt != tmp) {
			pr_err("err: controls mismatch, strings=%zu, ctl=%zu\n",
				cnt, tmp);
			*clk_info = NULL;
			return -EINVAL;
		}
		clock_cntl_support = true;
+27 −1
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019, 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
@@ -164,6 +164,19 @@ int msm_ais_enable_clocks(void)
		return rc;
	}

	if ((new_early_cam_dev->pdev == NULL) ||
		(new_early_cam_dev->early_cam_clk_info == NULL) ||
		(new_early_cam_dev->early_cam_clk == NULL) ||
		(new_early_cam_dev->num_clk == 0)) {
		rc = -EINVAL;
		pr_err("%s: Clock details uninitialised %d %pK %pK %pK %zd\n",
			__func__, rc, new_early_cam_dev->pdev,
			new_early_cam_dev->early_cam_clk_info,
			new_early_cam_dev->early_cam_clk,
			new_early_cam_dev->num_clk);
		return rc;
	}

	rc = msm_camera_clk_enable(&new_early_cam_dev->pdev->dev,
		new_early_cam_dev->early_cam_clk_info,
		new_early_cam_dev->early_cam_clk,
@@ -366,6 +379,19 @@ static int msm_early_cam_probe(struct platform_device *pdev)
		pr_err("%s:%d early_cam enable_vreg failed\n", __func__,
		__LINE__);

	if ((new_early_cam_dev->pdev == NULL) ||
		(new_early_cam_dev->early_cam_clk_info == NULL) ||
		(new_early_cam_dev->early_cam_clk == NULL) ||
		(new_early_cam_dev->num_clk == 0)) {
		rc = -EINVAL;
		pr_err("%s: Clock details uninitialised %d %pK %pK %pK %zd\n",
			__func__, rc, new_early_cam_dev->pdev,
			new_early_cam_dev->early_cam_clk_info,
			new_early_cam_dev->early_cam_clk,
			new_early_cam_dev->num_clk);
		return rc;
	}

	rc = msm_camera_clk_enable(&new_early_cam_dev->pdev->dev,
		new_early_cam_dev->early_cam_clk_info,
		new_early_cam_dev->early_cam_clk,