mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: florian.fainelli@broadcom.com, tglx@kernel.org
Cc: bcm-kernel-feedback-list@broadcom.com, radu@rendec.net,
	cernekee@gmail.com, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH] irqchip/bcm7038-l1: Fix potential stale handlers on probe failure
Date: Wed,  2 Dec 2026 19:29:37 +0800	[thread overview]
Message-ID: <20261202-85cdeb22ca-irqchip-bcm7038@mail.sdu.edu.cn> (raw)

IRQ-domain creation can fail after the per-CPU parent handlers have been
installed. Freeing the controller without clearing those handlers leaves
them referencing freed storage.

Track each installed parent IRQ and detach its handler before releasing
the controller. Also unwind partially initialized CPU resources.

This issue was found by our static analysis tool under development.

Fixes: 5f7f0317ed28 ("IRQCHIP: Add new driver for BCM7038-style level 1 interrupt controllers")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/irqchip/irq-bcm7038-l1.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 54a8557ef557..5cf1fd8e8b3b 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -48,6 +48,7 @@ struct bcm7038_l1_chip {
 };
 
 struct bcm7038_l1_cpu {
+	unsigned int		parent_irq;
 	void __iomem		*map_base;
 	u32			mask_cache[];
 };
@@ -267,6 +268,7 @@ static int bcm7038_l1_init_one(struct device_node *dn, unsigned int idx,
 	if (of_property_read_bool(dn, "brcm,irq-can-wake"))
 		enable_irq_wake(parent_irq);
 
+	cpu->parent_irq = parent_irq;
 	irq_set_chained_handler_and_data(parent_irq, bcm7038_l1_irq_handle,
 					 intc);
 
@@ -408,7 +410,7 @@ static int bcm7038_l1_probe(struct platform_device *pdev, struct device_node *pa
 			if (idx)
 				break;
 			pr_err("failed to remap intc L1 registers\n");
-			goto out_free;
+			goto out_unmap;
 		}
 	}
 
@@ -440,12 +442,18 @@ static int bcm7038_l1_probe(struct platform_device *pdev, struct device_node *pa
 		struct bcm7038_l1_cpu *cpu = intc->cpus[idx];
 
 		if (cpu) {
+			if (cpu->parent_irq) {
+				irq_set_chained_handler_and_data(cpu->parent_irq, NULL, NULL);
+				synchronize_irq(cpu->parent_irq);
+				if (of_property_read_bool(dn, "brcm,irq-can-wake"))
+					disable_irq_wake(cpu->parent_irq);
+				irq_dispose_mapping(cpu->parent_irq);
+			}
 			if (cpu->map_base)
 				iounmap(cpu->map_base);
 			kfree(cpu);
 		}
 	}
-out_free:
 	kfree(intc);
 	return ret;
 }

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244

                 reply	other threads:[~2026-12-02 11:29 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-bcm7038@mail.sdu.edu.cn \
    --to=liguangshuo@mail.sdu.edu.cn \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=cernekee@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --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®