[4/9] clk: qcom: Don't reference clk_init_data after registration
diff mbox series

Message ID 20190731193517.237136-5-sboyd@kernel.org
State New, archived
Headers show
Series
  • Make clk_hw::init NULL after clk registration
Related show

Commit Message

Stephen Boyd July 31, 2019, 7:35 p.m. UTC
A future patch is going to change semantics of clk_register() so that
clk_hw::init is guaranteed to be NULL after a clk is registered. Avoid
referencing this member here so that we don't run into NULL pointer
exceptions.

Cc: Taniya Das <tdas@codeaurora.org>
Cc: Andy Gross <agross@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---

Please ack so I can take this through clk tree

 drivers/clk/qcom/clk-rpmh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Taniya Das Aug. 4, 2019, 5:49 p.m. UTC | #1
On 8/1/2019 1:05 AM, Stephen Boyd wrote:
> A future patch is going to change semantics of clk_register() so that
> clk_hw::init is guaranteed to be NULL after a clk is registered. Avoid
> referencing this member here so that we don't run into NULL pointer
> exceptions.
> 
> Cc: Taniya Das <tdas@codeaurora.org>
> Cc: Andy Gross <agross@kernel.org>
> Signed-off-by: Stephen Boyd <sboyd@kernel.org>


Acked-by: Taniya Das <tdas@codeaurora.org>

> ---
> 
> Please ack so I can take this through clk tree
> 
>   drivers/clk/qcom/clk-rpmh.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
> index c3fd632af119..7a8a84dcb70d 100644
> --- a/drivers/clk/qcom/clk-rpmh.c
> +++ b/drivers/clk/qcom/clk-rpmh.c
> @@ -396,6 +396,7 @@ static int clk_rpmh_probe(struct platform_device *pdev)
>   	hw_clks = desc->clks;
>   
>   	for (i = 0; i < desc->num_clks; i++) {
> +		const char *name = hw_clks[i]->init->name;
>   		u32 res_addr;
>   		size_t aux_data_len;
>   		const struct bcm_db *data;
> @@ -426,8 +427,7 @@ static int clk_rpmh_probe(struct platform_device *pdev)
>   
>   		ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
>   		if (ret) {
> -			dev_err(&pdev->dev, "failed to register %s\n",
> -				hw_clks[i]->init->name);
> +			dev_err(&pdev->dev, "failed to register %s\n", name);
>   			return ret;
>   		}
>   	}
>
Stephen Boyd Aug. 14, 2019, 12:24 a.m. UTC | #2
Quoting Stephen Boyd (2019-07-31 12:35:12)
> A future patch is going to change semantics of clk_register() so that
> clk_hw::init is guaranteed to be NULL after a clk is registered. Avoid
> referencing this member here so that we don't run into NULL pointer
> exceptions.
> 
> Cc: Taniya Das <tdas@codeaurora.org>
> Cc: Andy Gross <agross@kernel.org>
> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
> ---

Applied to clk-next

Patch
diff mbox series

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index c3fd632af119..7a8a84dcb70d 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -396,6 +396,7 @@  static int clk_rpmh_probe(struct platform_device *pdev)
 	hw_clks = desc->clks;
 
 	for (i = 0; i < desc->num_clks; i++) {
+		const char *name = hw_clks[i]->init->name;
 		u32 res_addr;
 		size_t aux_data_len;
 		const struct bcm_db *data;
@@ -426,8 +427,7 @@  static int clk_rpmh_probe(struct platform_device *pdev)
 
 		ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
 		if (ret) {
-			dev_err(&pdev->dev, "failed to register %s\n",
-				hw_clks[i]->init->name);
+			dev_err(&pdev->dev, "failed to register %s\n", name);
 			return ret;
 		}
 	}