]> git.itanic.dy.fi Git - linux-stable/commitdiff
clk: st: Hold reference returned by of_get_parent()
authorLiang He <windhl@126.com>
Tue, 28 Jun 2022 14:24:15 +0000 (22:24 +0800)
committerStephen Boyd <sboyd@kernel.org>
Fri, 19 Aug 2022 21:34:44 +0000 (14:34 -0700)
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>
drivers/clk/st/clkgen-fsyn.c
drivers/clk/st/clkgen-mux.c

index 582a22c049194afbb25a201dc431d142c30ac7ac..d820292a381d0a78c818775b9b316c17f2d79e78 100644 (file)
@@ -987,6 +987,7 @@ static void __init st_of_quadfs_setup(struct device_node *np,
        const char *pll_name, *clk_parent_name;
        void __iomem *reg;
        spinlock_t *lock;
+       struct device_node *parent_np;
 
        /*
         * First check for reg property within the node to keep backward
@@ -994,7 +995,9 @@ static void __init st_of_quadfs_setup(struct device_node *np,
         */
        reg = of_iomap(np, 0);
        if (!reg) {
-               reg = of_iomap(of_get_parent(np), 0);
+               parent_np = of_get_parent(np);
+               reg = of_iomap(parent_np, 0);
+               of_node_put(parent_np);
                if (!reg) {
                        pr_err("%s: Failed to get base address\n", __func__);
                        return;
index ee39af7a0b7215411b607940a5c52a4c989cfaf9..596e939ad905e02b5ba195c3ec16cc43bd2d6e56 100644 (file)
@@ -56,6 +56,7 @@ static void __init st_of_clkgen_mux_setup(struct device_node *np,
        void __iomem *reg;
        const char **parents;
        int num_parents = 0;
+       struct device_node *parent_np;
 
        /*
         * First check for reg property within the node to keep backward
@@ -63,7 +64,9 @@ static void __init st_of_clkgen_mux_setup(struct device_node *np,
         */
        reg = of_iomap(np, 0);
        if (!reg) {
-               reg = of_iomap(of_get_parent(np), 0);
+               parent_np = of_get_parent(np);
+               reg = of_iomap(parent_np, 0);
+               of_node_put(parent_np);
                if (!reg) {
                        pr_err("%s: Failed to get base address\n", __func__);
                        return;