mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] irqchip/bcm7038-l1: Fix potential stale handlers on probe failure
@ 2026-12-02 11:29 Guangshuo Li
  0 siblings, 0 replies; only message in thread
From: Guangshuo Li @ 2026-12-02 11:29 UTC (permalink / raw)
  To: florian.fainelli, tglx
  Cc: bcm-kernel-feedback-list, radu, cernekee, linux-mips,
	linux-kernel, linux-arm-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02 11:29 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:29 [PATCH] irqchip/bcm7038-l1: Fix potential stale handlers 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®