From: Nicholas Krause Date: Wed, 3 Feb 2016 00:17:59 +0000 (-0500) Subject: gpio: davinci: Fix possible NULL pointer deference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6f434e8585ac5e4256d894819bf76d02bc2ed3c;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git gpio: davinci: Fix possible NULL pointer deference This fixes a possible NULL pointer deference in the function, davinci_gpio_probe due to the function, gpio2regs being able to return a NULL pointer if it rans to get the registers for the gpio devices on a davinci board. Furthermore if this does arise return -ENXIO to signal callers that this case has arisen and avoiding setting the regs or other pointer values on the Signed-off-by: Nicholas Krause Reviewed-by: Alexandre Courbot Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 845edffbcc3f..96332f19e775 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -257,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) spin_lock_init(&chips[i].lock); regs = gpio2regs(base); + if (!regs) + return -ENXIO; chips[i].regs = regs; chips[i].set_data = ®s->set_data; chips[i].clr_data = ®s->clr_data;