mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: tglx@kernel.org
Cc: radu@rendec.net, prabhakar.mahadev-lad.rj@bp.renesas.com,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure
Date: Wed,  2 Dec 2026 19:30:18 +0800	[thread overview]
Message-ID: <20261202-85cdeb22ca-irqchip-renesas@mail.sdu.edu.cn> (raw)

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

                 reply	other threads:[~2026-12-02 11:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261202-85cdeb22ca-irqchip-renesas@mail.sdu.edu.cn \
    --to=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=radu@rendec.net \
    --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®