From: Radu Rendec <radu@rendec.net>
To: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>, tglx@kernel.org
Cc: prabhakar.mahadev-lad.rj@bp.renesas.com,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure
Date: Sat, 05 Dec 2026 21:30:06 -0500 [thread overview]
Message-ID: <1efb1571c28144ad5ea5604ad7e7256fd254c260.camel@rendec.net> (raw)
In-Reply-To: <20261202-85cdeb22ca-irqchip-renesas@mail.sdu.edu.cn>
On Wed, 2026-12-02 at 19:30 +0800, Guangshuo Li wrote:
> An IRQ setup failure releases the managed controller data but leaves its
> domain and syscore callbacks registered. Partially created IRQ mappings
> also retain controller pointers.
>
> Dispose of each mapping after its managed handler is released, then
> remove the domain. Register the syscore callbacks only after IRQ setup
> succeeds.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: 61adc4813d67 ("irqchip/renesas-rzv2h: Add CA55 software interrupt support")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
> ---
> drivers/irqchip/irq-renesas-rzv2h.c | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-renesas-rzv2h.c b/drivers/irqchip/irq-renesas-rzv2h.c
> index 806be528b6d4..d9b9d82e44c2 100644
> --- a/drivers/irqchip/irq-renesas-rzv2h.c
> +++ b/drivers/irqchip/irq-renesas-rzv2h.c
> @@ -793,6 +793,16 @@ static irqreturn_t rzv2h_icu_swint_irq(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> +static void rzv2h_icu_remove_domain(void *data)
> +{
> + irq_domain_remove(data);
This has the same problem I flagged a week ago when I reviewed your
other series: it removes the domain without disposing of the irq
mappings. When it's called because probe() fails, it's probably not an
issue because no downstream interrupts exist at that point. But the
devres binding survives the probe(), so at least in theory your remove
callback can be called later with active mappings.
> +}
> +
> +static void rzv2h_icu_dispose_mapping(void *data)
> +{
> + irq_dispose_mapping((unsigned long)data);
> +}
> +
> static int rzv2h_icu_setup_irqs(struct platform_device *pdev, struct irq_domain *irq_domain)
> {
> const struct rzv2h_hw_info *hw_info = rzv2h_icu_data->info;
> @@ -815,6 +825,11 @@ static int rzv2h_icu_setup_irqs(struct platform_device *pdev, struct irq_domain
> "failed to create int-ca55-%u IRQ mapping\n", i);
> }
>
> + ret = devm_add_action_or_reset(dev, rzv2h_icu_dispose_mapping,
> + (void *)(unsigned long)virq);
> + if (ret)
> + return ret;
> +
> ret = devm_request_irq(dev, virq, rzv2h_icu_swint_irq, 0, dev_name(dev),
> (void *)(uintptr_t)i);
> if (ret)
> @@ -844,6 +859,11 @@ static int rzv2h_icu_setup_irqs(struct platform_device *pdev, struct irq_domain
> if (!virq)
> return dev_err_probe(dev, -EINVAL, "failed to create icu-error-ca55 IRQ mapping\n");
>
> + ret = devm_add_action_or_reset(dev, rzv2h_icu_dispose_mapping,
> + (void *)(unsigned long)virq);
> + if (ret)
> + return ret;
> +
> ret = devm_request_irq(dev, virq, rzv2h_icu_error_irq, 0, dev_name(dev), rzv2h_icu_data);
> if (ret)
> return ret;
> @@ -901,14 +921,18 @@ static int rzv2h_icu_probe_common(struct platform_device *pdev, struct device_no
> goto pm_put;
> }
>
> - rzv2h_icu_data->info = hw_info;
> + ret = devm_add_action_or_reset(dev, rzv2h_icu_remove_domain, irq_domain);
I understand why you did this, but I personally don't like the
proliferation of explicit devm_add_action_or_reset() calls.
I'm working on a patch series that adds a devres managed variant of
irq_domain_create_hierarchy() and attempts to also solve the automatic
disposal of irq mappings. I hope to be able to post it within the next
couple of days, so perhaps it's better to wait for it.
> + if (ret)
> + goto pm_put;
>
> - register_syscore(&rzv2h_irqc_syscore);
> + rzv2h_icu_data->info = hw_info;
>
> ret = rzv2h_icu_setup_irqs(pdev, irq_domain);
> if (ret)
> goto pm_put;
>
> + register_syscore(&rzv2h_irqc_syscore);
> +
> /*
> * coccicheck complains about a missing put_device call before returning, but it's a false
> * positive. We still need dev after successfully returning from this function.
>
> base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
prev parent reply other threads:[~2026-12-06 2:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 11:30 Guangshuo Li
2026-12-06 2:30 ` Radu Rendec [this message]
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=1efb1571c28144ad5ea5604ad7e7256fd254c260.camel@rendec.net \
--to=radu@rendec.net \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=tglx@kernel.org \
/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
all inboxes | Powered by JetHome®