From: Wentao Liang <redacted>
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. While
there add support for EPROBE_DEFER to the error handling.
This patch has been generated with LLM assistance.
Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module")
Cc: <redacted>
Signed-off-by: Wentao Liang <redacted>
Link: https://patch.msgid.link/20261103100520.1309743-1-vulab@iscas.ac.cn (local)
[mkl: add EPROBE_DEFER handling, convert Assisted-by tag into prose]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/sun4i_can.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
index af52285d5a4e..2a169dbf7813 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,10 +843,10 @@ 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;
+ err = PTR_ERR(clk);
+ dev_err_probe(&pdev->dev, err, "unable to request clock\n");
goto exit;
}
--
2.53.0