Skip to content

Commit 27a6e1b

Browse files
clementlegerbebarino
authored andcommitted
clk: add missing of_node_put() in "assigned-clocks" property parsing
When returning from of_parse_phandle_with_args(), the np member of the of_phandle_args structure should be put after usage. Add missing of_node_put() calls in both __set_clk_parents() and __set_clk_rates(). Fixes: 86be408 ("clk: Support for clock parents and rates assigned from device tree") Signed-off-by: Clément Léger <clement.leger@bootlin.com> Link: https://lore.kernel.org/r/20230131083227.10990-1-clement.leger@bootlin.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent fe15c26 commit 27a6e1b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/clk/clk-conf.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
3333
else
3434
return rc;
3535
}
36-
if (clkspec.np == node && !clk_supplier)
36+
if (clkspec.np == node && !clk_supplier) {
37+
of_node_put(clkspec.np);
3738
return 0;
39+
}
3840
pclk = of_clk_get_from_provider(&clkspec);
41+
of_node_put(clkspec.np);
3942
if (IS_ERR(pclk)) {
4043
if (PTR_ERR(pclk) != -EPROBE_DEFER)
4144
pr_warn("clk: couldn't get parent clock %d for %pOF\n",
@@ -48,10 +51,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
4851
if (rc < 0)
4952
goto err;
5053
if (clkspec.np == node && !clk_supplier) {
54+
of_node_put(clkspec.np);
5155
rc = 0;
5256
goto err;
5357
}
5458
clk = of_clk_get_from_provider(&clkspec);
59+
of_node_put(clkspec.np);
5560
if (IS_ERR(clk)) {
5661
if (PTR_ERR(clk) != -EPROBE_DEFER)
5762
pr_warn("clk: couldn't get assigned clock %d for %pOF\n",
@@ -93,10 +98,13 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
9398
else
9499
return rc;
95100
}
96-
if (clkspec.np == node && !clk_supplier)
101+
if (clkspec.np == node && !clk_supplier) {
102+
of_node_put(clkspec.np);
97103
return 0;
104+
}
98105

99106
clk = of_clk_get_from_provider(&clkspec);
107+
of_node_put(clkspec.np);
100108
if (IS_ERR(clk)) {
101109
if (PTR_ERR(clk) != -EPROBE_DEFER)
102110
pr_warn("clk: couldn't get clock %d for %pOF\n",

0 commit comments

Comments
 (0)