Skip to contentSkip to conversation

irqchip/mchp-eic: Fix clock reference leak in mchp_eic_probe()

PATCH Applied Wentao Liang 2 participants 2 messages Sep 16 – Oct 15

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/mchp-eic: Fix clock reference leak in mchp_eic_probe()

of_clk_get_by_name() returns the clock with an elevated reference count that mchp_eic_probe() keeps for the lifetime of the driver, but none of the probe error paths drops it, so the reference is leaked whenever probe fails after the clock has been obtained.

Put the reference in the error cleanup. The clk_prepare_enable() failure path must jump there directly as it cannot call clk_disable_unprepare() on a clock that was never enabled.

Fixes 00fa3461c86d ("irqchip/mchp-eic: Add support for the Microchip EIC")
---
 drivers/irqchip/irq-mchp-eic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/irqchip/irq-mchp-eic.c +3 -1
index be007d325e67..5250e6baff63 100644
@@ -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:
Signature · 1 line
2.34.1
merge bot Applied
#1 lore raw
The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     af9c707eb065a7d48eb92dc15acdb4346acf5db0
Gitweb:        https://git.kernel.org/tip/af9c707eb065a7d48eb92dc15acdb4346acf5db0
Author:        Wentao Liang <[email protected]>
AuthorDate:    Wed, 16 Sep 2026 19:03:49 
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 15 Oct 2026 11:50:47 +02:00

irqchip/mchp-eic: Fix clock reference leak in mchp_eic_probe()

of_clk_get_by_name() returns the clock with an elevated reference count that mchp_eic_probe() keeps for the lifetime of the driver, but none of the probe error paths drops it, so the reference is leaked whenever probe fails after the clock has been obtained.

Put the reference in the error cleanup. The clk_prepare_enable() failure path must jump there directly as it cannot call clk_disable_unprepare() on a clock that was never enabled.

Fixes 00fa3461c86d ("irqchip/mchp-eic: Add support for the Microchip EIC")
---
 drivers/irqchip/irq-mchp-eic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/irqchip/irq-mchp-eic.c +3 -1
index be007d3..5250e6b 100644
@@ -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: