Skip to content

Commit 4299733

Browse files
windhlbebarino
authored andcommitted
clk: st: Hold reference returned by of_get_parent()
We should hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance. Fixes: 3efe64e ("clk: st: clkgen-fsyn: search reg within node or parent") Fixes: 810251b ("clk: st: clkgen-mux: search reg within node or parent") Signed-off-by: Liang He <windhl@126.com> Link: https://lore.kernel.org/r/20220628142416.169808-1-windhl@126.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 02bd544 commit 4299733

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

drivers/clk/st/clkgen-fsyn.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,14 +987,17 @@ static void __init st_of_quadfs_setup(struct device_node *np,
987987
const char *pll_name, *clk_parent_name;
988988
void __iomem *reg;
989989
spinlock_t *lock;
990+
struct device_node *parent_np;
990991

991992
/*
992993
* First check for reg property within the node to keep backward
993994
* compatibility, then if reg doesn't exist look at the parent node
994995
*/
995996
reg = of_iomap(np, 0);
996997
if (!reg) {
997-
reg = of_iomap(of_get_parent(np), 0);
998+
parent_np = of_get_parent(np);
999+
reg = of_iomap(parent_np, 0);
1000+
of_node_put(parent_np);
9981001
if (!reg) {
9991002
pr_err("%s: Failed to get base address\n", __func__);
10001003
return;

drivers/clk/st/clkgen-mux.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ static void __init st_of_clkgen_mux_setup(struct device_node *np,
5656
void __iomem *reg;
5757
const char **parents;
5858
int num_parents = 0;
59+
struct device_node *parent_np;
5960

6061
/*
6162
* First check for reg property within the node to keep backward
6263
* compatibility, then if reg doesn't exist look at the parent node
6364
*/
6465
reg = of_iomap(np, 0);
6566
if (!reg) {
66-
reg = of_iomap(of_get_parent(np), 0);
67+
parent_np = of_get_parent(np);
68+
reg = of_iomap(parent_np, 0);
69+
of_node_put(parent_np);
6770
if (!reg) {
6871
pr_err("%s: Failed to get base address\n", __func__);
6972
return;

0 commit comments

Comments
 (0)