Skip to contentSkip to conversation

ARM: mmp: Add missing clk_disable_unprepare() in mmp_dt_init_timer()

PATCH In review Chen Lifu 1 participant 2 messages Sep 7, 2022 – Oct 8, 2022

Subsystems (3)
lore
Share & tools
lore

Chen Lifu

author
#0 lore raw

PATCH 1/1 ARM: mmp: Add missing clk_disable_unprepare() in mmp_dt_init_timer()

mmp_dt_init_timer() may have called clk_prepare_enable() before return from failed branches, add missing clk_disable_unprepare() in these cases.

Fixes f36797ee4380 ("ARM: mmp/mmp2: dt: enable the clock")
---
 arch/arm/mach-mmp/time.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/mach-mmp/time.c +6 -2
index 41b2e8abc9e6..6d2db1fea1be 100644
@@ -207,16 +207,20 @@ static int __init mmp_dt_init_timer(struct device_node *np)
 	} else {
 		rate = 3250000;
 	}
 
 	irq = irq_of_parse_and_map(np, 0);
-	if (!irq)
+	if (!irq) {
+		clk_disable_unprepare(clk);
 		return -EINVAL;
+	}
 
 	mmp_timer_base = of_iomap(np, 0);
-	if (!mmp_timer_base)
+	if (!mmp_timer_base) {
+		clk_disable_unprepare(clk);
 		return -ENOMEM;
+	}
 
 	mmp_timer_init(irq, rate);
 	return 0;
 }
 
Signature · 1 line
2.37.1
author
#1 lore raw
Quoted 26 lines · Chen Lifu

mmp_dt_init_timer() may have called clk_prepare_enable() before return from failed branches, add missing clk_disable_unprepare() in these cases.

Fixes f36797ee4380 ("ARM: mmp/mmp2: dt: enable the clock")
---
  arch/arm/mach-mmp/time.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/mach-mmp/time.c +3 -1
index 41b2e8abc9e6..6d2db1fea1be 100644
@@ -207,16 +207,20 @@ static int __init mmp_dt_init_timer(struct device_node *np)
  	} else {
  		rate = 3250000;
  	}
 
  	irq = irq_of_parse_and_map(np, 0);
-	if (!irq)
+	if (!irq) {
+		clk_disable_unprepare(clk);
  		return -EINVAL;
+	}
 
  	mmp_timer_base = of_iomap(np, 0);

arch/arm/mach-mmp/time.c static int __init mmp_dt_init_timer(struct device_node *np) · line 226

Quoted 10 lines
arch/arm/mach-mmp/time.c +3 -1
-	if (!mmp_timer_base)
+	if (!mmp_timer_base) {
+		clk_disable_unprepare(clk);
  		return -ENOMEM;
+	}
 
  	mmp_timer_init(irq, rate);
  	return 0;
  }
 

friendly ping ...