mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure
@ 2026-12-02 11:30 Guangshuo Li
  0 siblings, 0 replies; only message 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] only message in thread

only message in thread, other threads:[~2026-12-02 11:30 UTC | newest]

Thread overview: (only message) (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

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®