mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start
authorLiang He <windhl@126.com>
Fri, 1 Jul 2022 12:41:12 +0000 (20:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:09:31 +0000 (11:09 +0200)
[ Upstream commit 7a9f743ceead60ed454c46fbc3085ee9a79cbebb ]

We should call of_node_put() for the reference 'uctl_node' returned by
of_get_parent() which will increase the refcount. Otherwise, there will
be a refcount leak bug.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/mips/cavium-octeon/octeon-platform.c

index 2ecc8d1b0539530f63c63626209e5dbafd6fcabb..f295be8763906d3f637f9d3a67730c92de9adb66 100644 (file)
@@ -130,11 +130,12 @@ static void octeon2_usb_clocks_start(struct device *dev)
                                         "refclk-frequency", &clock_rate);
                if (i) {
                        dev_err(dev, "No UCTL \"refclk-frequency\"\n");
+                       of_node_put(uctl_node);
                        goto exit;
                }
                i = of_property_read_string(uctl_node,
                                            "refclk-type", &clock_type);
-
+               of_node_put(uctl_node);
                if (!i && strcmp("crystal", clock_type) == 0)
                        is_crystal_clock = true;
        }