Skip to contentSkip to conversation

ARM: OMAP: avoid NULL pointer dereference when no PMIC is configured

PATCH New Daniel Mack 2 participants 3 messages Dec 18, 2011 – Dec 20, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: OMAP: avoid NULL pointer dereference when no PMIC is configured

---
 arch/arm/mach-omap2/vp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/vp.c +5 -0
index 66bd700..5407173 100644
@@ -41,6 +41,11 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
 	u32 val, sys_clk_rate, timeout, waittime;
 	u32 vddmin, vddmax, vstepmin, vstepmax;
 
+	if (!voltdm->pmic) {
+		pr_err("%s: No PMIC configured.\n", __func__, voltdm->name);
+		return;
+	}
+
 	if (!voltdm->read || !voltdm->write) {
 		pr_err("%s: No read/write API for accessing vdd_%s regs\n",
 			__func__, voltdm->name);
Signature · 1 line
1.7.7.4
#1 lore raw

PATCH 1/1 ARM: OMAP: avoid NULL pointer dereference when no PMIC is configured

Hi Daniel,

Quoted 11 lines · Daniel Mack
---
 arch/arm/mach-omap2/vp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/vp.c +0 -0
index 66bd700..5407173 100644

arch/arm/mach-omap2/vp.c void __init omap_vp_init(struct voltagedomain *voltdm) · line 45

Quoted 5 lines
arch/arm/mach-omap2/vp.c +2 -0
@@ -41,6 +41,11 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
 	u32 val, sys_clk_rate, timeout, waittime;
 	u32 vddmin, vddmax, vstepmin, vstepmax;
 
+	if (!voltdm->pmic) {
+		pr_err("%s: No PMIC configured.\n", __func__, voltdm->name);

You are passing two parameters to pr_err(), but use only one... Also, I don't know if this is the right thing to do here, so Cc'ed Paul and Kevin.

Quoted 6 lines
arch/arm/mach-omap2/vp.c +3 -0
+		return;
+	}
+
 	if (!voltdm->read || !voltdm->write) {
 		pr_err("%s: No read/write API for accessing vdd_%s regs\n",
 			__func__, voltdm->name);
Signature · 2 lines
Regards,
Igor.
#2 lore raw

PATCH 1/1 ARM: OMAP: avoid NULL pointer dereference when no PMIC is configured

Hi Igor,

Quoted 15 lines · Igor Grinberg
Quoted 14 lines · Daniel Mack
---
 arch/arm/mach-omap2/vp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/vp.c +0 -0
index 66bd700..5407173 100644
@@ -41,6 +41,11 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
 	u32 val, sys_clk_rate, timeout, waittime;
 	u32 vddmin, vddmax, vstepmin, vstepmax;
 
Quoted 4 lines

arch/arm/mach-omap2/vp.c void __init omap_vp_init(struct voltagedomain *voltdm) · line 45

Quoted 2 lines
arch/arm/mach-omap2/vp.c +2 -0
+	if (!voltdm->pmic) {
+		pr_err("%s: No PMIC configured.\n", __func__, voltdm->name);

You are passing two parameters to pr_err(), but use only one...

Of course not. I wonder why the compiler didn't yell at me about that.

Quoted 2 lines

Also, I don't know if this is the right thing to do here, so Cc'ed Paul and Kevin.

That is the other question ideed. In the case I was facing on a custom board, I was running into this without any configured PMIC. Clearly, derferencing a NULL pointer here is no good thing to do.

Thanks,
Daniel