[PATCH 4.19 020/106] clk: sprd: Dont reference clk_init_data after registration

From: Greg Kroah-Hartman
Date: Sun Oct 06 2019 - 13:28:48 EST


From: Stephen Boyd <sboyd@xxxxxxxxxx>

[ Upstream commit f6c90df8e7e33c3dc33d4d7471bc42c232b0510e ]

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: Chunyan Zhang <zhang.chunyan@xxxxxxxxxx>
Cc: Baolin Wang <baolin.wang@xxxxxxxxxx>
Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx>
Link: https://lkml.kernel.org/r/20190731193517.237136-8-sboyd@xxxxxxxxxx
Acked-by: Baolin Wang <baolin.wang@xxxxxxxxxx>
Acked-by: Chunyan Zhang <zhang.chunyan@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/clk/sprd/common.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c
index e038b04472061..8bdab1c3013b8 100644
--- a/drivers/clk/sprd/common.c
+++ b/drivers/clk/sprd/common.c
@@ -71,16 +71,17 @@ int sprd_clk_probe(struct device *dev, struct clk_hw_onecell_data *clkhw)
struct clk_hw *hw;

for (i = 0; i < clkhw->num; i++) {
+ const char *name;

hw = clkhw->hws[i];
-
if (!hw)
continue;

+ name = hw->init->name;
ret = devm_clk_hw_register(dev, hw);
if (ret) {
dev_err(dev, "Couldn't register clock %d - %s\n",
- i, hw->init->name);
+ i, name);
return ret;
}
}
--
2.20.1