[PATCH] irqchip/mchp-eic: fix clk reference leak on probe error paths

Haotian Zhang vulab at iscas.ac.cn
Thu Oct 8 10:44:12 PDT 2026


mchp_eic_probe() acquires the peripheral clock with
of_clk_get_by_name(), which takes a reference on the underlying struct
clk, but the error paths only call clk_disable_unprepare() and never
clk_put(). When clk_prepare_enable() fails, or when of_irq_parse_one(),
the IRQ argument validation or irq_domain_create_hierarchy() fails, the
probe function jumps to the cleanup labels, frees the private data and
returns with the clock reference still held.

Release the clock reference with clk_put() on all error paths that occur
after the clock has been successfully looked up.

Fixes: 00fa3461c86d ("irqchip/mchp-eic: Add support for the Microchip EIC")
Assisted-by: DeepSeek-V4.1-Flash
Signed-off-by: Haotian Zhang <vulab at iscas.ac.cn>
---
 drivers/irqchip/irq-mchp-eic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-mchp-eic.c b/drivers/irqchip/irq-mchp-eic.c
index be007d325e67..5250e6baff63 100644
--- a/drivers/irqchip/irq-mchp-eic.c
+++ b/drivers/irqchip/irq-mchp-eic.c
@@ -233,7 +233,7 @@ static int mchp_eic_probe(struct platform_device *pdev, struct device_node *pare
 
 	ret = clk_prepare_enable(eic->clk);
 	if (ret)
-		goto unmap;
+		goto clk_put;
 
 	for (i = 0; i < MCHP_EIC_NIRQ; i++) {
 		struct of_phandle_args irq;
@@ -270,6 +270,8 @@ static int mchp_eic_probe(struct platform_device *pdev, struct device_node *pare
 
 clk_unprepare:
 	clk_disable_unprepare(eic->clk);
+clk_put:
+	clk_put(eic->clk);
 unmap:
 	iounmap(eic->base);
 free:
-- 
2.25.1




More information about the linux-arm-kernel mailing list