]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
gpio: at91: add sanity check for the NULL pointer
authorWu, Josh <Josh.wu@atmel.com>
Wed, 7 May 2014 08:50:45 +0000 (16:50 +0800)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Mon, 26 May 2014 22:10:45 +0000 (00:10 +0200)
We need check the NULL pointer as at91_pio_get_port() may return NULL.

Also print a error message when at91_pio_get_port() failed otherwise we
cannot notice the failure.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
drivers/gpio/at91_gpio.c

index 0b70071871ce8046577fab9453c195d2281bc81d..6517af162815ea8e5715dabb390ed46de12f4617 100644 (file)
@@ -34,6 +34,7 @@ static struct at91_port *at91_pio_get_port(unsigned port)
 #endif
 #endif
        default:
+               printf("Error: at91_gpio: Fail to get PIO base!\n");
                return NULL;
        }
 }
@@ -200,7 +201,7 @@ int at91_set_pio_output(unsigned port, u32 pin, int value)
        struct at91_port *at91_port = at91_pio_get_port(port);
        u32 mask;
 
-       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
+       if (at91_port && (port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                writel(mask, &at91_port->idr);
                writel(mask, &at91_port->pudr);