From: Zhipeng Wang <[email protected]>
probe() creates the IRQ domain with irq_domain_create_linear() and only
tears it down on the remove() path. On the probe() error path after the
domain has been created (the fsl,num-irqs sanity check), the single
error label just calls clk_disable_unprepare() and returns, leaking the
freshly created domain. The domain-creation failure path happens to
share the same label correctly only because the domain is NULL there.
Create the domain with devm_irq_domain_instantiate() so it is removed
automatically on unbind and on any probe() failure after it has been
created. This fixes the leak on the sanity-check error path and lets
remove() drop its explicit irq_domain_remove().
Fixes: 28528fca4908 ("irqchip/imx-irqsteer: Add multi output interrupts support")
Signed-off-by: Zhipeng Wang <[email protected]>
---
drivers/irqchip/irq-imx-irqsteer.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/irqchip/irq-imx-irqsteer.c b/drivers/irqchip/irq-imx-irqsteer.c
index 1b8d0c8eedb9..c1df84551efa 100644
--- a/drivers/irqchip/irq-imx-irqsteer.c
+++ b/drivers/irqchip/irq-imx-irqsteer.c
@@ -237,11 +237,18 @@ static int imx_irqsteer_probe(struct platform_device *pdev)
if (irqsteer_has_chanctrl(data->devtype_data))
writel_relaxed(BIT(data->channel), data->regs + CHANCTRL);
- data->domain = irq_domain_create_linear(dev_fwnode(&pdev->dev), data->reg_num * 32,
- &imx_irqsteer_domain_ops, data);
- if (!data->domain) {
+ struct irq_domain_info info = {
+ .fwnode = dev_fwnode(&pdev->dev),
+ .size = data->reg_num * 32,
+ .hwirq_max = data->reg_num * 32,
+ .ops = &imx_irqsteer_domain_ops,
+ .host_data = data,
+ };
+
+ data->domain = devm_irq_domain_instantiate(&pdev->dev, &info);
+ if (IS_ERR(data->domain)) {
dev_err(&pdev->dev, "failed to create IRQ domain\n");
- ret = -ENOMEM;
+ ret = PTR_ERR(data->domain);
goto out;
}
irq_domain_set_pm_device(data->domain, &pdev->dev);
@@ -285,8 +292,6 @@ static void imx_irqsteer_remove(struct platform_device *pdev)
NULL, NULL);
}
- irq_domain_remove(irqsteer_data->domain);
-
clk_disable_unprepare(irqsteer_data->ipg_clk);
}
--
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.