[PATCH] can: sun4i_can: Use devm_clk_get() for the CAN clock

Wentao Liang vulab at iscas.ac.cn
Tue Nov 3 02:05:20 PST 2026


sun4ican_probe() obtains the CAN clock with of_clk_get(), but neither
the probe error paths nor sun4ican_remove() ever call clk_put(), so the
clock reference is leaked both when probing fails and when the driver is
unbound.

Use devm_clk_get() so that the reference is released with the device.

Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/net/can/sun4i_can.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
index af52285d5a4e..9f5d31063b13 100644
--- a/drivers/net/can/sun4i_can.c
+++ b/drivers/net/can/sun4i_can.c
@@ -819,7 +819,6 @@ static void sun4ican_remove(struct platform_device *pdev)
 
 static int sun4ican_probe(struct platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node;
 	struct clk *clk;
 	struct reset_control *reset = NULL;
 	void __iomem *addr;
@@ -844,7 +843,7 @@ static int sun4ican_probe(struct platform_device *pdev)
 		}
 	}
 
-	clk = of_clk_get(np, 0);
+	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "unable to request clock\n");
 		err = -ENODEV;
-- 
2.34.1




More information about the linux-arm-kernel mailing list