Skip to contentSkip to conversation

davinci:Fix possible NULL pointer deference in the function davinci_gpio_probe

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

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 19 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 chips to avoid rather deferences to a NULL pointer by other functions in this gpio driver.

---
 drivers/gpio/gpio-davinci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-davinci.c +0 -0
index ec58f42..800227e 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 (!ret)
+                       return -ENXIO;

You haven't even tried to compile this one, have you?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 31 lines · nick
Quoted 22 lines · Alexandre Courbot
Quoted 21 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 chips to avoid rather deferences to a NULL pointer by other functions in this gpio driver.

---
 drivers/gpio/gpio-davinci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-davinci.c +0 -0
index ec58f42..800227e 100644
@@ -257,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
                spin_lock_init(&chips[i].lock);
 
Quoted 6 lines

drivers/gpio/gpio-davinci.c static int davinci_gpio_probe(struct platform_device *pdev) · line 261

Quoted 3 lines
drivers/gpio/gpio-davinci.c +2 -0
                regs = gpio2regs(base);
+               if (!ret)
+                       return -ENXIO;

You haven't even tried to compile this one, have you?

Quoted 3 lines

Weird my compiler didn't fail when building with allmodconfig on x86_64 unless this driver is not enabled by default under that build config it should have failed. Sorry about that Alexandre I will resend and fix up that build issue.

Davinci is ARM, so it will not be included in a x86 build.