Skip to contentSkip to conversation

davinci:Fix possible NULL pointer deference in the function davinci_gpio_probe

PATCH Alexandre Courbot 2 participants 2 messages Feb 3, 2016 – Feb 15, 2016 1 message not in the archive GPIO

lore
Share & tools
lore

Alexandre Courbot

author Reviewed-by
#1 lore raw
In reply to a message not in the archive
Quoted 17 lines · Nicholas Krause

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

---
 drivers/gpio/gpio-davinci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-davinci.c +0 -0
index ec58f42..1cc527d 100644

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...

#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Nicholas Krause

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

Patch applied with Alex' review tag.

Yours,
Linus Walleij