From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
kernel@pengutronix.de, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH net-next 05/13] can: sun4i_can: sun4ican_probe(): fix clk leak on unbound
Date: Thu, 19 Nov 2026 22:58:41 +0100 [thread overview]
Message-ID: <20261119220936.155728-6-mkl@pengutronix.de> (raw)
In-Reply-To: <20261119220936.155728-1-mkl@pengutronix.de>
From: Wentao Liang <vulab@iscas.ac.cn>
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: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20261103100520.1309743-1-vulab@iscas.ac.cn
[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
next prev parent reply other threads:[~2026-11-19 22:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 21:58 [PATCH net-next 0/13] pull-request: can-next 2026-11-19 Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 01/13] MAINTAINERS: add entry for PEAK-System CAN drivers Marc Kleine-Budde
2026-11-19 22:18 ` netdev-bot+sinfo
2026-11-19 22:24 ` Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 02/13] can: raw: remove redundant NULL check before netdev_hold() Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 03/13] can: dev: remove unused safe_candev_priv() Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 04/13] can: convert to DEFINE_SIMPLE_DEV_PM_OPS() Marc Kleine-Budde
2026-11-19 21:58 ` Marc Kleine-Budde [this message]
2026-11-19 21:58 ` [PATCH net-next 06/13] can: cc770: don't discard the IRQ lookup error in probe Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 07/13] can: sun4i_can: " Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 08/13] can: at91_can: " Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 09/13] can: janz-ican3: " Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 10/13] can: ifi_canfd: " Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 11/13] can: remove Softing CANcard driver Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 12/13] can: ucan: fix repeated word 'is' in comment Marc Kleine-Budde
2026-11-19 21:58 ` [PATCH net-next 13/13] can: xilinx_can: set CAN FD flags on received frames Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119220936.155728-6-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox