Commit a1d4ef1a authored by Fabien Dessenne's avatar Fabien Dessenne Committed by Linus Walleij

pinctrl: stm32: fix optional IRQ support to gpios

To act as an interrupt controller, a gpio bank relies on the
"interrupt-parent" of the pin controller.
When this optional "interrupt-parent" misses, do not create any IRQ domain.

This fixes a "NULL pointer in stm32_gpio_domain_alloc()" kernel crash when
the interrupt-parent = <exti> property is not declared in the Device Tree.

Fixes: 0eb9f683 ("pinctrl: Add IRQ support to STM32 gpios")
Signed-off-by: default avatarFabien Dessenne <fabien.dessenne@foss.st.com>
Link: https://lore.kernel.org/r/20220627142350.742973-1-fabien.dessenne@foss.st.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent fbc24ebc
...@@ -1338,17 +1338,19 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode ...@@ -1338,17 +1338,19 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
bank->secure_control = pctl->match_data->secure_control; bank->secure_control = pctl->match_data->secure_control;
spin_lock_init(&bank->lock); spin_lock_init(&bank->lock);
if (pctl->domain) {
/* create irq hierarchical domain */ /* create irq hierarchical domain */
bank->fwnode = fwnode; bank->fwnode = fwnode;
bank->domain = irq_domain_create_hierarchy(pctl->domain, 0, bank->domain = irq_domain_create_hierarchy(pctl->domain, 0, STM32_GPIO_IRQ_LINE,
STM32_GPIO_IRQ_LINE, bank->fwnode, bank->fwnode, &stm32_gpio_domain_ops,
&stm32_gpio_domain_ops, bank); bank);
if (!bank->domain) { if (!bank->domain) {
err = -ENODEV; err = -ENODEV;
goto err_clk; goto err_clk;
} }
}
err = gpiochip_add_data(&bank->gpio_chip, bank); err = gpiochip_add_data(&bank->gpio_chip, bank);
if (err) { if (err) {
...@@ -1510,6 +1512,8 @@ int stm32_pctl_probe(struct platform_device *pdev) ...@@ -1510,6 +1512,8 @@ int stm32_pctl_probe(struct platform_device *pdev)
pctl->domain = stm32_pctrl_get_irq_domain(pdev); pctl->domain = stm32_pctrl_get_irq_domain(pdev);
if (IS_ERR(pctl->domain)) if (IS_ERR(pctl->domain))
return PTR_ERR(pctl->domain); return PTR_ERR(pctl->domain);
if (!pctl->domain)
dev_warn(dev, "pinctrl without interrupt support\n");
/* hwspinlock is optional */ /* hwspinlock is optional */
hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0); hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment