Skip to contentSkip to conversation

avoid NULL pointer in gpio1_interrupt

PATCH In review Olaf Hering 2 participants 2 messages Sep 26, 2006 Linux for power macintosh

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avoid NULL pointer in gpio1_interrupt

gpio1_interrupt() may dereference a NULL pointer if ioremap() fails. But, maybe no gpio interrupt happens in the first place?

---
 drivers/macintosh/via-pmu.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/macintosh/via-pmu.c +6 -1
Index: linux-2.6.18/drivers/macintosh/via-pmu.c
===================================================================
@@ -336,8 +336,10 @@ int __init find_via_pmu(void)
 			if (gaddr != OF_BAD_ADDR)
 				gpio_reg = ioremap(gaddr, 0x10);
 		}
-		if (gpio_reg == NULL)
+		if (gpio_reg == NULL) {
 			printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n");
+			goto fail_gpio;
+		}
 	} else
 		pmu_kind = PMU_UNKNOWN;
 
@@ -366,6 +368,9 @@ int __init find_via_pmu(void)
 	return 1;
  fail:
 	of_node_put(vias);
+	iounmap(gpio_reg);
+	gpio_reg = NULL;
+ fail_gpio:
 	vias = NULL;
 	return 0;
 }
#1 lore raw
Quoted 2 lines · Olaf Hering

gpio1_interrupt() may dereference a NULL pointer if ioremap() fails. But, maybe no gpio interrupt happens in the first place?

Nah, they would happen. Good catch tho I fail to see how ioremap would fail that early during boot :)

Ben.