Skip to content

Commit a1d4ef1

Browse files
Fabien Dessennelinusw
authored andcommitted
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: 0eb9f68 ("pinctrl: Add IRQ support to STM32 gpios") Signed-off-by: Fabien Dessenne <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent fbc24eb commit a1d4ef1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/pinctrl/stm32/pinctrl-stm32.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,16 +1338,18 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
13381338
bank->secure_control = pctl->match_data->secure_control;
13391339
spin_lock_init(&bank->lock);
13401340

1341-
/* create irq hierarchical domain */
1342-
bank->fwnode = fwnode;
1341+
if (pctl->domain) {
1342+
/* create irq hierarchical domain */
1343+
bank->fwnode = fwnode;
13431344

1344-
bank->domain = irq_domain_create_hierarchy(pctl->domain, 0,
1345-
STM32_GPIO_IRQ_LINE, bank->fwnode,
1346-
&stm32_gpio_domain_ops, bank);
1345+
bank->domain = irq_domain_create_hierarchy(pctl->domain, 0, STM32_GPIO_IRQ_LINE,
1346+
bank->fwnode, &stm32_gpio_domain_ops,
1347+
bank);
13471348

1348-
if (!bank->domain) {
1349-
err = -ENODEV;
1350-
goto err_clk;
1349+
if (!bank->domain) {
1350+
err = -ENODEV;
1351+
goto err_clk;
1352+
}
13511353
}
13521354

13531355
err = gpiochip_add_data(&bank->gpio_chip, bank);
@@ -1510,6 +1512,8 @@ int stm32_pctl_probe(struct platform_device *pdev)
15101512
pctl->domain = stm32_pctrl_get_irq_domain(pdev);
15111513
if (IS_ERR(pctl->domain))
15121514
return PTR_ERR(pctl->domain);
1515+
if (!pctl->domain)
1516+
dev_warn(dev, "pinctrl without interrupt support\n");
15131517

15141518
/* hwspinlock is optional */
15151519
hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0);

0 commit comments

Comments
 (0)