clk/qoriq: Hold reference returned by of_get_parent()
PATCH 1/1 clk/qoriq: Hold reference returned by of_get_parent()
In legacy_init_clockgen(), we need to hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance.
Beside, in create_sysclk(), we need to call of_node_put() on 'sysclk' also for refcount balance.
Fixes 0dfc86b3173f ("clk: qoriq: Move chip-specific knowledge into driver")
Signed-off-by Liang He <[email protected]>
---
these bugs are found in 5.19rc2
these bugs are confirmed not fixed by lore.kernel.org these bugs are compiled tested in 5.19rc2 with at91_dt_defconfig
drivers/clk/clk-qoriq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/clk/clk-qoriq.c +8 -2
@@ -1063,8 +1063,13 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);*/ static void __init legacy_init_clockgen (struct device_node *np) { -if (!clockgen.node) -_clockgen_init (of_get_parent (np), true); +if (!clockgen.node) { +struct device_node *tp; + + tp =of_get_parent (np); +_clockgen_init (tp, true); +of_node_put (tp); + } }/* Legacy node */
@@ -1159,6 +1164,7 @@ static struct clk * __init create_sysclk(const char *name) sysclk =of_get_child_by_name (clockgen.node,"sysclk" );if (sysclk) { clk =sysclk_from_fixed (sysclk, name); +of_node_put (sysclk);if (!IS_ERR (clk))return clk; }
Signature · 1 line
2.25.1