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 <xerofoify@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Nicholas Krause 2016-02-02 19:17:59 -05:00 committed by Linus Walleij
parent ed07247dbf
commit d6f434e858
1 changed files with 2 additions and 0 deletions

View File

@ -257,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
spin_lock_init(&chips[i].lock); spin_lock_init(&chips[i].lock);
regs = gpio2regs(base); regs = gpio2regs(base);
if (!regs)
return -ENXIO;
chips[i].regs = regs; chips[i].regs = regs;
chips[i].set_data = &regs->set_data; chips[i].set_data = &regs->set_data;
chips[i].clr_data = &regs->clr_data; chips[i].clr_data = &regs->clr_data;