[PATCH] ARM: mvebu: mvebu-soc-id: fix missing clk_put() on error path

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


get_soc_id_by_pci() takes a reference on the PCIe clock with
of_clk_get_by_name(), but when clk_prepare_enable() fails it jumps to
the clk_err label, which only drops the device node references and never
calls clk_put(). The struct clk and the clock core reference it holds
are leaked on that error path.

Release the clock reference before jumping to clk_err.

Fixes: af8d1c63afcb ("ARM: mvebu: Add support to get the ID and the revision of a SoC")
Assisted-by: DeepSeek-V4.1-Flash
Signed-off-by: Haotian Zhang <vulab at iscas.ac.cn>
---
 arch/arm/mach-mvebu/mvebu-soc-id.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.c b/arch/arm/mach-mvebu/mvebu-soc-id.c
index 850ed3ea3cc4..84831798357e 100644
--- a/arch/arm/mach-mvebu/mvebu-soc-id.c
+++ b/arch/arm/mach-mvebu/mvebu-soc-id.c
@@ -85,6 +85,7 @@ static int __init get_soc_id_by_pci(void)
 	ret = clk_prepare_enable(clk);
 	if (ret) {
 		pr_err("cannot enable clock\n");
+		clk_put(clk);
 		goto clk_err;
 	}
 
-- 
2.25.1




More information about the linux-arm-kernel mailing list