lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 3 Mar 2023 14:58:58 +0530
From:   Taniya Das <quic_tdas@...cinc.com>
To:     Andy Gross <agross@...nel.org>,
        Michael Turquette <mturquette@...libre.com>,
        Stephen Boyd <sboyd@...nel.org>
CC:     Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        <linux-arm-msm@...r.kernel.org>, <linux-clk@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, Taniya Das <quic_tdas@...cinc.com>
Subject: [PATCH 1/2] clk: qcom: common: Handle invalid index error

Introduce start_index to handle invalid index error
seen when there are two clock descriptors assigned
to the same clock controller.

[ 3.600604] qcom_cc_clk_hw_get: invalid index 5
[ 3.625251] qcom_cc_clk_hw_get: invalid index 6
[ 3.648190] qcom_cc_clk_hw_get: invalid index 7

Fixes: 120c15528390 ("clk: qcom: Migrate to clk_hw based registration and OF APIs")
Signed-off-by: Taniya Das <quic_tdas@...cinc.com>
---
 drivers/clk/qcom/common.c | 12 ++++++++----
 drivers/clk/qcom/common.h |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index 75f09e6e057e..0e80535b61f2 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -21,6 +21,7 @@ struct qcom_cc {
 	struct qcom_reset_controller reset;
 	struct clk_regmap **rclks;
 	size_t num_rclks;
+	u32 rclks_start_index;
 };

 const
@@ -226,12 +227,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,
 	struct qcom_cc *cc = data;
 	unsigned int idx = clkspec->args[0];

-	if (idx >= cc->num_rclks) {
+	if (idx >= cc->rclks_start_index && idx < cc->num_rclks)
+		return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL;
+	else if (idx < cc->rclks_start_index && idx >= cc->num_rclks)
 		pr_err("%s: invalid index %u\n", __func__, idx);
-		return ERR_PTR(-EINVAL);
-	}

-	return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL;
+	return ERR_PTR(-EINVAL);
+
 }

 int qcom_cc_really_probe(struct platform_device *pdev,
@@ -281,6 +283,8 @@ int qcom_cc_really_probe(struct platform_device *pdev,

 	cc->rclks = rclks;
 	cc->num_rclks = num_clks;
+	if (desc->start_index)
+		cc->rclks_start_index = desc->start_index;

 	qcom_cc_drop_protected(dev, cc);

diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h
index 9c8f7b798d9f..924f36af55b3 100644
--- a/drivers/clk/qcom/common.h
+++ b/drivers/clk/qcom/common.h
@@ -23,6 +23,7 @@ struct qcom_cc_desc {
 	const struct regmap_config *config;
 	struct clk_regmap **clks;
 	size_t num_clks;
+	u32 start_index;
 	const struct qcom_reset_map *resets;
 	size_t num_resets;
 	struct gdsc **gdscs;
--
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ