pinctrl: bcm2835: Don't remove an unregistered GPIO chip
Subsystems (4)
PATCH 1/1 pinctrl: bcm2835: Don't remove an unregistered GPIO chip
If the devm_pinctrl_register() function fails, bcm2835_pinctrl_probe() calls gpiochip_remove() before gpiochip_add_data() has registered the GPIO chip.
This means that upon failure the gpio_chip.gpiodev
is NULL resulting in a null pointer dereference
inside the gpiochip_remove() function.
Remove the unnecessary function call to gpiochip_remove(). No GPIO cleanup is required because the GPIO chip has not yet been registered. Without this change there is potential for a kernel panic upon registration failure
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 1 - 1 file changed, 1 deletion(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +0 -1
@@ -1350,7 +1350,6 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) pc->pctl_desc = *pdata->pctl_desc; pc->pctl_dev =devm_pinctrl_register (dev, &pc->pctl_desc, pc);if (IS_ERR (pc->pctl_dev)) { -gpiochip_remove (&pc->gpio_chip);return PTR_ERR (pc->pctl_dev); }
Signature · 1 line
2.53.0
Linus Walleij
maintainerQuoted 8 lines · Daniel McCarthy
If the
devm_pinctrl_register()function fails,bcm2835_pinctrl_probe()callsgpiochip_remove()beforegpiochip_add_data()has registered the GPIO chip.This means that upon failure the gpio_chip.gpiodev
is NULL resulting in a null pointer dereference
inside thegpiochip_remove()function.
Quoted 7 lines
Remove the unnecessary function call to
gpiochip_remove(). No GPIO cleanup is required because the GPIO chip has not yet been registered. Without this change there is potential for a kernel panic upon registration failureFixes 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs")Signed-off-by Daniel McCarthy <[email protected]>
Patch applied as nonurgent fix.
Yours,
Linus Walleij