Skip to contentSkip to conversation

clk: oxnas: Hold reference returned by of_get_parent()

PATCH Applied Liang He 2 participants 2 messages Jun 28, 2022 – Aug 19, 2022 Common clk

v2 of 5 Applied Latest is v5 →

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH v2 1/1 clk: oxnas: Hold reference returned by of_get_parent()

In oxnas_stdclk_probe(), we need to hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance.

Fixes 0bbd72b4c64f ("clk: Add Oxford Semiconductor OXNAS Standard Clocks")

---
changelog:

v2: change 'tp' with 'parent_np', change title format to xx:yy:zz
v1: hold reference returned by of_get_parent()

v1-link: https://lore.kernel.org/all/[email protected]/

Patched file has been copmiled test in 5.19rc2.

 drivers/clk/clk-oxnas.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/clk-oxnas.c +4 -2
index cda5e258355b..584e293156ad 100644
@@ -207,7 +207,7 @@ static const struct of_device_id oxnas_stdclk_dt_ids[] = {
 
 static int oxnas_stdclk_probe(struct platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node;
+	struct device_node *np = pdev->dev.of_node, *parent_np;
 	const struct oxnas_stdclk_data *data;
 	struct regmap *regmap;
 	int ret;
@@ -215,7 +215,9 @@ static int oxnas_stdclk_probe(struct platform_device *pdev)
 
 	data = of_device_get_match_data(&pdev->dev);
 
-	regmap = syscon_node_to_regmap(of_get_parent(np));
+	parent_np = of_get_parent(np);
+	regmap = syscon_node_to_regmap(parent_np);
+	of_node_put(parent_np);
 	if (IS_ERR(regmap)) {
 		dev_err(&pdev->dev, "failed to have parent regmap\n");
 		return PTR_ERR(regmap);
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw

Quoting Liang He (2022-06-28 07:31:55)

Quoted 7 lines

In oxnas_stdclk_probe(), we need to hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance.

Fixes 0bbd72b4c64f ("clk: Add Oxford Semiconductor OXNAS Standard Clocks")

---

Applied to clk-next