Skip to contentSkip to conversation

arm: omap4: hsmmc: check for null pointer

PATCH Superseded Balaji T K 3 participants 3 messages Apr 3, 2012 – Apr 10, 2012

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Balaji T K

author
#0 lore raw

PATCH 1/1 arm: omap4: hsmmc: check for null pointer

platform_device pdev can be NULL if CONFIG_MMC_OMAP_HS is not set. Add check for NULL pointer

Fixes the following boot crash seen with omap4sdp and omap4panda when MMC is disabled.

Unable to handle kernel NULL pointer dereference at virtual address 0000008c
pgd = c0004000
[0000008c] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0    Not tainted  (3.4.0-rc1-05971-ga4dfa82 #4)
PC is at omap_4430sdp_init+0x184/0x410
LR is at device_add+0x1a0/0x664
---
 arch/arm/mach-omap2/board-4430sdp.c    |    6 +++++-
 arch/arm/mach-omap2/board-omap4panda.c |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/board-4430sdp.c +5 -1
index a39fc4b..1ce771d 100644
@@ -526,8 +526,12 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
 	struct omap2_hsmmc_info *c;
 
 	omap_hsmmc_init(controllers);
-	for (c = controllers; c->mmc; c++)
+	for (c = controllers; c->mmc; c++) {
+		/* pdev can be null if CONFIG_MMC_OMAP_HS is not set */
+		if (!c->pdev)
+			continue;
 		omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
+	}
 
 	return 0;
 }
arch/arm/mach-omap2/board-omap4panda.c +5 -1
index d8c0e89..104fd6d 100644
@@ -278,8 +278,12 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
 	struct omap2_hsmmc_info *c;
 
 	omap_hsmmc_init(controllers);
-	for (c = controllers; c->mmc; c++)
+	for (c = controllers; c->mmc; c++) {
+		/* pdev can be null if CONFIG_MMC_OMAP_HS is not set */
+		if (!c->pdev)
+			continue;
 		omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
+	}
 
 	return 0;
 }
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 arm: omap4: hsmmc: check for null pointer

Quoted 15 lines · Balaji T K

platform_device pdev can be NULL if CONFIG_MMC_OMAP_HS is not set. Add check for NULL pointer

Fixes the following boot crash seen with omap4sdp and omap4panda when MMC is disabled.

Unable to handle kernel NULL pointer dereference at virtual address 0000008c
pgd = c0004000
[0000008c] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0 ? ?Not tainted ?(3.4.0-rc1-05971-ga4dfa82 #4)
PC is at omap_4430sdp_init+0x184/0x410
LR is at device_add+0x1a0/0x664
Quoted 2 lines

Thanks for the fix Balaji.

maintainer
#2 lore raw

PATCH 1/1 arm: omap4: hsmmc: check for null pointer

In reply to Balaji T K
Quoted 48 lines · Balaji T K

platform_device pdev can be NULL if CONFIG_MMC_OMAP_HS is not set. Add check for NULL pointer

Fixes the following boot crash seen with omap4sdp and omap4panda when MMC is disabled.

Unable to handle kernel NULL pointer dereference at virtual address 0000008c
pgd = c0004000
[0000008c] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0    Not tainted  (3.4.0-rc1-05971-ga4dfa82 #4)
PC is at omap_4430sdp_init+0x184/0x410
LR is at device_add+0x1a0/0x664
---
 arch/arm/mach-omap2/board-4430sdp.c    |    6 +++++-
 arch/arm/mach-omap2/board-omap4panda.c |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/board-4430sdp.c +5 -1
index a39fc4b..1ce771d 100644
@@ -526,8 +526,12 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
 	struct omap2_hsmmc_info *c;
 
 	omap_hsmmc_init(controllers);
-	for (c = controllers; c->mmc; c++)
+	for (c = controllers; c->mmc; c++) {
+		/* pdev can be null if CONFIG_MMC_OMAP_HS is not set */
+		if (!c->pdev)
+			continue;
 		omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
+	}
 
 	return 0;
 }
arch/arm/mach-omap2/board-omap4panda.c +0 -0
index d8c0e89..104fd6d 100644
@@ -278,8 +278,12 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
 	struct omap2_hsmmc_info *c;
 
 	omap_hsmmc_init(controllers);

arch/arm/mach-omap2/board-omap4panda.c static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) · line 289

Quoted 10 lines
arch/arm/mach-omap2/board-omap4panda.c +5 -1
-	for (c = controllers; c->mmc; c++)
+	for (c = controllers; c->mmc; c++) {
+		/* pdev can be null if CONFIG_MMC_OMAP_HS is not set */
+		if (!c->pdev)
+			continue;
 		omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
+	}
 
 	return 0;
 }

Uhh cut and paste duplicate code.. Let's get rid of that while at it. Can you please update this so we have only one copy of omap4_twl6030_hsmmc_init in some place, maybe in one of the arch/arm/mach-omap2/*twl*.c files?

Thanks,

Tony