Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 3efe64ef5186 ("clk: st: clkgen-fsyn: search reg within node or parent")
Fixes: 810251b0d36a ("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>

authored by

Liang He and committed by
Stephen Boyd
42997330 02bd544f

+8 -2
+4 -1
drivers/clk/st/clkgen-fsyn.c
··· 987 987 const char *pll_name, *clk_parent_name; 988 988 void __iomem *reg; 989 989 spinlock_t *lock; 990 + struct device_node *parent_np; 990 991 991 992 /* 992 993 * First check for reg property within the node to keep backward ··· 995 994 */ 996 995 reg = of_iomap(np, 0); 997 996 if (!reg) { 998 - reg = of_iomap(of_get_parent(np), 0); 997 + parent_np = of_get_parent(np); 998 + reg = of_iomap(parent_np, 0); 999 + of_node_put(parent_np); 999 1000 if (!reg) { 1000 1001 pr_err("%s: Failed to get base address\n", __func__); 1001 1002 return;
+4 -1
drivers/clk/st/clkgen-mux.c
··· 56 56 void __iomem *reg; 57 57 const char **parents; 58 58 int num_parents = 0; 59 + struct device_node *parent_np; 59 60 60 61 /* 61 62 * First check for reg property within the node to keep backward ··· 64 63 */ 65 64 reg = of_iomap(np, 0); 66 65 if (!reg) { 67 - reg = of_iomap(of_get_parent(np), 0); 66 + parent_np = of_get_parent(np); 67 + reg = of_iomap(parent_np, 0); 68 + of_node_put(parent_np); 68 69 if (!reg) { 69 70 pr_err("%s: Failed to get base address\n", __func__); 70 71 return;