davinci:Fix possible NULL pointer deference in the function davinci_gpio_probe
Quoted 19 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 the chips to avoid rather deferences to a NULL pointer by other functions in this gpio driver.Signed-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 (!ret) +return -ENXIO ;
You haven't even tried to compile this one, have you?
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_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 the chips to avoid rather deferences to a NULL pointer by other functions in this gpio driver.Signed-off-by Nicholas Krause <[email protected]>--- drivers/gpio/gpio-davinci.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpio/gpio-davinci.c +0
-0@@ -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
-0regs =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_64unless 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.