Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peng Fan" <peng.fan@linux.dev>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear()
Date: Thu, 03 Dec 2026 09:55:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-247511@kernel.org> (raw)
In-Reply-To: <20261203-imx-intmux-v2-7-a6db1eed3b5f@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] irqchip/imx-intmux: devm_irq_domain_create_linear() inverts
  clock/PM teardown
--

commit 7858358f254863ea504bc6fe05b47317cf04b64e
Author: Peng Fan <peng.fan@nxp.com>

irqchip/imx-intmux: Use devm_irq_domain_create_linear()

This commit switches per-channel IRQ domain creation to
devm_irq_domain_create_linear() and removes the explicit
irq_domain_remove() calls from the probe error path and
imx_intmux_remove().

> diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
> index 369132b4677ba..eeba45f312be9 100644
> --- a/drivers/irqchip/irq-imx-intmux.c
> +++ b/drivers/irqchip/irq-imx-intmux.c
> @@ -260,8 +260,9 @@ static int imx_intmux_probe(struct platform_device *pdev)
>  			goto out;
>  		}
>  
> -		domain = irq_domain_create_linear(of_fwnode_handle(np), 32, &imx_intmux_domain_ops,
> -					       &data->irqchip_data[i]);
> +		domain = devm_irq_domain_create_linear(&pdev->dev, dev_fwnode(&pdev->dev), 32,
> +						       &imx_intmux_domain_ops,
> +						       &data->irqchip_data[i]);
>  		if (!domain) {
>  			ret = -ENOMEM;
>  			dev_err(&pdev->dev, "failed to create IRQ domain\n");
> @@ -301,7 +302,6 @@ static int imx_intmux_probe(struct platform_device *pdev)
>  		for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
>  			irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
>  							     hwirq));
> -		irq_domain_remove(data->irqchip_data[i].domain);
>  		irq_dispose_mapping(data->irqchip_data[i].irq);
>  	}
>  	pm_runtime_disable(&pdev->dev);
> @@ -335,7 +335,6 @@ static void imx_intmux_remove(struct platform_device *pdev)
>  		for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
>  			irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
>  							     hwirq));
> -		irq_domain_remove(data->irqchip_data[i].domain);
>  		irq_dispose_mapping(data->irqchip_data[i].irq);
>  	}
>  

[Severity: Medium]
Can deferring irq_domain_remove() to devres leave the channel IRQ domains
published after child mappings, runtime PM, and ipg_clk have already been
torn down?

Both the probe error path and imx_intmux_remove() dispose child mappings,
call pm_runtime_disable(), and call clk_disable_unprepare(data->ipg_clk)
before returning to the driver core.  The channel domains stay on
irq_domain_list until device_unbind_cleanup() runs devres_release_all().

When fw_devlink=off or fw_devlink=permissive is in effect, a consumer can
resolve an interrupt in that window after the disposal loop has finished:

CPU0                                CPU1
imx_intmux_remove()
  irq_dispose_mapping(...)
  pm_runtime_disable()
  clk_disable_unprepare(ipg_clk)
                                    of_irq_get()
                                      irq_create_of_mapping()
device_unbind_cleanup()
  devres_release_all()
    irq_domain_remove(domain)
    kfree(data)
                                    request_irq()
                                      ...
                                        imx_intmux_irq_unmask()
                                        <-- use-after-free

irq_domain_remove() frees the domain without disposing entries in the
linear revmap array, and devres then frees data, leaving the new irq_desc
with dangling domain and chip_data pointers.

If CONFIG_PM is disabled, irq_chip_pm_get() also returns 0, allowing a
concurrent request_irq() in that window to call imx_intmux_irq_unmask()
and access CHANIER(idx) after ipg_clk has been disabled.

Either keeping explicit irq_domain_remove() before pm_runtime_disable()
and clk_disable_unprepare(), or managing ipg_clk and runtime PM via devres
registered before devm_irq_domain_create_linear() (as irq-imx-irqsteer.c
does), would preserve reverse teardown order.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com?part=7

  reply	other threads:[~2026-12-03  9:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
2026-12-03  9:29 ` [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels Peng Fan
2026-12-03  9:52   ` sashiko-bot
2026-12-03  9:29 ` [PATCH v2 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
2026-12-03  9:53   ` sashiko-bot
2026-12-03  9:29 ` [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path Peng Fan
2026-12-03  9:50   ` sashiko-bot
2026-12-03  9:29 ` [PATCH v2 4/8] irqchip/imx-intmux: Reject zero channel count Peng Fan
2026-12-03  9:29 ` [PATCH v2 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
2026-12-03  9:40   ` sashiko-bot
2026-12-03  9:29 ` [PATCH v2 6/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
2026-12-03  9:46   ` sashiko-bot
2026-12-03  9:29 ` [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
2026-12-03  9:55   ` sashiko-bot [this message]
2026-12-03  9:29 ` [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() Peng Fan
2026-12-03 10:01   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-247511@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=peng.fan@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox