[PATCH] arm: omap2: control: Hold reference returned by of_get_child_by_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In omap_control_init(), there are two bugs in fact:

(1) we need to call of_node_put() for 'scm_conf' in fail path and when
    it is not used anymore.
(2) we should hold refernece returned by of_get_child_by_name() for
    'clk_np' and then use it to call of_node_put() when it is not used
    anymore.


Signed-off-by: Liang He <windhl@xxxxxxx>
---
 arch/arm/mach-omap2/control.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index c514a9602269..4c23ccfcee5d 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -793,7 +793,7 @@ int __init omap2_control_base_init(void)
  */
 int __init omap_control_init(void)
 {
-	struct device_node *np, *scm_conf;
+	struct device_node *np, *scm_conf, *clk_np;
 	const struct of_device_id *match;
 	const struct omap_prcm_init_data *data;
 	int ret;
@@ -817,13 +817,17 @@ int __init omap_control_init(void)
 				goto of_node_put;
 			}
 
-			if (of_get_child_by_name(scm_conf, "clocks")) {
+			clk_np = of_get_child_by_name(scm_conf, "clocks");
+			if (clk_np) {
+				of_node_put(clk_np);
 				ret = omap2_clk_provider_init(scm_conf,
 							      data->index,
 							      syscon, NULL);
 				if (ret)
 					goto of_node_put;
 			}
+
+			of_node_put(scm_conf);
 		} else {
 			/* No scm_conf found, direct access */
 			ret = omap2_clk_provider_init(np, data->index, NULL,
@@ -842,6 +846,7 @@ int __init omap_control_init(void)
 	return 0;
 
 of_node_put:
+	of_node_put(scm_conf);
 	of_node_put(np);
 	return ret;
 
-- 
2.25.1




[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux