davinci:Fix possible NULL pointer deference in the function davinci_gpio_probe
A message that is not in the archive (sent off-list or not yet received): [email protected]
Alexandre Courbot
Reviewed-byQuoted 17 lines · Nicholas Krause
This fixes a possible NULL pointer deference in the function,
davinci_gpio_probedue 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-ENXIOto signal callers that this case has arisen and avoiding setting the regs or other pointer values on theSigned-off-by Nicholas Krause <[email protected]>--- drivers/gpio/gpio-davinci.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpio/gpio-davinci.c +0
-0
drivers/gpio/gpio-davinci.c static int davinci_gpio_probe(struct platform_device *pdev) · line 261
Quoted 5 lines
drivers/gpio/gpio-davinci.c +2
-0@@ -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 ;
Ok, a bit futile maybe but this *may* happen in theory...
Quoted 8 lines · Nicholas Krause
This fixes a possible NULL pointer deference in the function,
davinci_gpio_probedue 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-ENXIOto signal callers that this case has arisen and avoiding setting the regs or other pointer values on theSigned-off-by Nicholas Krause <[email protected]>
Patch applied with Alex' review tag.
Yours,
Linus Walleij