[POWERPC] Avoid NULL pointer in gpio1_interrupt
authorOlaf Hering <olaf@aepfle.de>
Tue, 26 Sep 2006 20:28:36 +0000 (22:28 +0200)
committerPaul Mackerras <paulus@samba.org>
Mon, 2 Oct 2006 10:27:26 +0000 (20:27 +1000)
gpio1_interrupt() may dereference a NULL pointer if ioremap() fails.
But, maybe no gpio interrupt happens in the first place?

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
drivers/macintosh/via-pmu.c

index dda03985dcf5b804cdf7c6724561012523660942..5710e01cef10418dc65432a46c277f35d282aff7 100644 (file)
@@ -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;
 
@@ -365,6 +367,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;
 }