* [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure
@ 2026-12-02 11:30 Guangshuo Li
2026-12-06 2:30 ` Radu Rendec
0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-12-02 11:30 UTC (permalink / raw)
To: tglx; +Cc: radu, prabhakar.mahadev-lad.rj, linux-kernel, linux-renesas-soc
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);
+}
+
+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);
+ 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure
2026-12-02 11:30 [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure Guangshuo Li
@ 2026-12-06 2:30 ` Radu Rendec
0 siblings, 0 replies; 2+ messages in thread
From: Radu Rendec @ 2026-12-06 2:30 UTC (permalink / raw)
To: Guangshuo Li, tglx
Cc: prabhakar.mahadev-lad.rj, linux-kernel, linux-renesas-soc
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-06 2:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 11:30 [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure Guangshuo Li
2026-12-06 2:30 ` Radu Rendec
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®