Skip to contentSkip to conversation

arm: smp-twd: check for uninitialized clock in twd_cpufreq_init

PATCH New Tero Kristo 3 participants 4 messages Feb 17, 2012 – Feb 18, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: smp-twd: check for uninitialized clock in twd_cpufreq_init

Non-smp platforms don't have local timer support, but the twd_cpufreq_init only checks for IS_ERR during init. Check against null also, to avoid crashes during cpufreq transitions on non-smp platforms.

---
 arch/arm/kernel/smp_twd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/kernel/smp_twd.c +1 -1
index 4285daa..dae8902 100644
@@ -129,7 +129,7 @@ static struct notifier_block twd_cpufreq_nb = {
 
 static int twd_cpufreq_init(void)
 {
-	if (!IS_ERR(twd_clk))
+	if (twd_clk && !IS_ERR(twd_clk))
 		return cpufreq_register_notifier(&twd_cpufreq_nb,
 			CPUFREQ_TRANSITION_NOTIFIER);
 
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/1 arm: smp-twd: check for uninitialized clock in twd_cpufreq_init

Quoted 6 lines · Tero Kristo

Non-smp platforms don't have local timer support, but the twd_cpufreq_init only checks for IS_ERR during init. Check against null also, to avoid crashes during cpufreq transitions on non-smp platforms.

---

I sent a patch for the same issue which Kevin reported.

Thread.
http://www.spinics.net/lists/arm-kernel/msg160275.html

arch/arm/kernel/smp_twd.c static struct notifier_block twd_cpufreq_nb = { · line 132

Quoted 13 lines

?arch/arm/kernel/smp_twd.c | ? ?2 +-
?1 files changed, 1 insertions(+), 1 deletions(-)

arch/arm/kernel/smp_twd.c +1 -1
index 4285daa..dae8902 100644
@@ -129,7 +129,7 @@ static struct notifier_block twd_cpufreq_nb = {
 
 ?static int twd_cpufreq_init(void)
 ?{
- ? ? ? if (!IS_ERR(twd_clk))
+ ? ? ? if (twd_clk && !IS_ERR(twd_clk))

Checking the clock node is not enoough because you can not have clock node and rely on calibration.. Testing twd_evt is safe to avoid the issue.

Regards
santosh

#2 lore raw

PATCH 1/1 arm: smp-twd: check for uninitialized clock in twd_cpufreq_init

Quoted 8 lines · Santosh
Quoted 6 lines · Tero Kristo

Non-smp platforms don't have local timer support, but the twd_cpufreq_init only checks for IS_ERR during init. Check against null also, to avoid crashes during cpufreq transitions on non-smp platforms.

---

I sent a patch for the same issue which Kevin reported.

Oh sorry for the noise then. I did a quick search for a similar patch but didn't find one. This patch can be ignored.

-Tero

Quoted 24 lines

Thread.
http://www.spinics.net/lists/arm-kernel/msg160275.html

arch/arm/kernel/smp_twd.c static struct notifier_block twd_cpufreq_nb = { · line 132

Quoted 13 lines
 arch/arm/kernel/smp_twd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/kernel/smp_twd.c +1 -1
index 4285daa..dae8902 100644
@@ -129,7 +129,7 @@ static struct notifier_block twd_cpufreq_nb = {
 
 static int twd_cpufreq_init(void)
 {
-       if (!IS_ERR(twd_clk))
+       if (twd_clk && !IS_ERR(twd_clk))

Checking the clock node is not enoough because you can not have clock node and rely on calibration.. Testing twd_evt is safe to avoid the issue.

Regards
santosh

#3 lore raw

PATCH 1/1 arm: smp-twd: check for uninitialized clock in twd_cpufreq_init

In reply to Tero Kristo

Hello.

Quoted 14 lines · Tero Kristo

Non-smp platforms don't have local timer support, but the twd_cpufreq_init only checks for IS_ERR during init. Check against null also, to avoid crashes during cpufreq transitions on non-smp platforms.

---
  arch/arm/kernel/smp_twd.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/kernel/smp_twd.c +0 -0
index 4285daa..dae8902 100644

arch/arm/kernel/smp_twd.c static struct notifier_block twd_cpufreq_nb = { · line 132

Quoted 5 lines
arch/arm/kernel/smp_twd.c +1 -1
@@ -129,7 +129,7 @@ static struct notifier_block twd_cpufreq_nb = {
 
  static int twd_cpufreq_init(void)
  {
-	if (!IS_ERR(twd_clk))
+	if (twd_clk&&  !IS_ERR(twd_clk))

Why not !IS_ERR_OR_NULL(twd_clk)?

WBR, Sergei