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 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel()
Date: Thu, 03 Dec 2026 10:01:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-247521@kernel.org> (raw)
In-Reply-To: <20261203-imx-intmux-v2-8-a6db1eed3b5f@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] irqchip/imx-intmux: lazy disable_irq() races with handler
teardown
--
commit 58ddadbb56d0e9d72dc72cc109e6fc29fd9722be
Author: Peng Fan <peng.fan@nxp.com>
irqchip/imx-intmux: Factor out imx_intmux_teardown_channel()
This commit factors the per-channel teardown sequence out of the probe
error path and imx_intmux_remove() into imx_intmux_teardown_channel().
> diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
> index eeba45f312be9..cce21ac8c21d5 100644
> --- a/drivers/irqchip/irq-imx-intmux.c
> +++ b/drivers/irqchip/irq-imx-intmux.c
> @@ -200,6 +200,21 @@ static void imx_intmux_irq_handler(struct irq_desc *desc)
> generic_handle_domain_irq(irqchip_data->domain, pos);
> }
>
> +static void imx_intmux_teardown_channel(struct intmux_data *data, int i)
> +{
> + /*
> + * Mask the parent interrupt and wait for a handler that is already
> + * running to finish before its handler data, chip and mappings are
> + * torn down. irq_dispose_mapping() installs no_irq_chip before its
> + * own synchronize_irq(), which loses the GIC active-state check.
> + */
> + disable_irq(data->irqchip_data[i].irq);
> + irq_set_chained_handler_and_data(data->irqchip_data[i].irq, NULL, NULL);
> + for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
> + irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, hwirq));
> + irq_dispose_mapping(data->irqchip_data[i].irq);
> +}
> +
[Severity: Medium]
Can disable_irq() leave the parent GIC SPI unmasked in hardware and let
imx_intmux_irq_handler() race with irq_set_chained_handler_and_data()?
On GICv3, neither gic_chip nor gic_eoimode1_chip implements .irq_disable,
and IRQ_DISABLE_UNLAZY is not set on the parent SPI. disable_irq()
therefore calls __irq_disable(desc, false), which only sets
IRQD_IRQ_DISABLED in software and skips mask_irq().
Unlike standard flow handlers, imx_intmux_irq_handler() runs without
checking irqd_irq_disabled() or setting IRQD_IRQ_INPROGRESS. Because
irq_set_chained_handler_and_data() clears handler_data before masking the
parent IRQ, a racing interrupt on another CPU can dereference NULL:
CPU0 CPU1
imx_intmux_teardown_channel()
disable_irq(irq)
__irq_disable(desc, false)
/* SPI still unmasked */
irq_set_chained_handler_and_data(
irq, NULL, NULL)
desc->...handler_data = NULL
<hardirq>
imx_intmux_irq_handler(desc)
irqchip_data = NULL
irqchip_data->chanidx
<-- NULL pointer dereference
__irq_do_set_handler(..., NULL)
mask_ack_irq(desc)
If imx_intmux_irq_handler() reads handler_data just before it is cleared,
irq_dispose_mapping() installs no_irq_chip before synchronize_irq(), losing
the GIC active-state check so teardown can disable ipg_clk and free
intmux_data while the handler is still running.
Setting IRQ_DISABLE_UNLAZY on the parent IRQ before calling disable_irq()
would ensure the parent SPI is masked in hardware before synchronize_irq()
runs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com?part=8
next prev parent reply other threads:[~2026-12-03 10:01 UTC|newest]
Thread overview: 17+ 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
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 [this message]
2026-12-03 14:14 ` [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
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-247521@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.