Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mkl@pengutronix.de
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	linux-can@vger.kernel.org, kernel@pengutronix.de,
	socketcan@hartkopp.net, dev.kurt@vandijck-laurijssen.be
Subject: Re: [PATCH net-next 06/12] can: sun4i_can: don't discard the IRQ lookup error in probe
Date: Thu, 19 Nov 2026 09:54:29 +0000	[thread overview]
Message-ID: <179508206916.3136.11316421181176601828@kernel.org> (raw)
In-Reply-To: <20261118092955.1283165-7-mkl@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In drivers/net/can/sun4i_can.c, sun4ican_probe() takes a clock
  reference with of_clk_get(np, 0) at line 847 and never releases it on…
- [Medium] The patch fixes the IRQ path.
- [Low] The commit message does not match the code.

--

can: sun4i_can: don't discard the IRQ lookup error in probe

This patch makes sun4ican_probe() return the error from platform_get_irq()
as is, instead of replacing it with -ENODEV. The goal is to let
-EPROBE_DEFER from of_irq_get() reach the driver core, so the probe is
retried once the interrupt controller appears.

Link: https://patch.msgid.link/2a7cb6e4e1b494efd4da512abbf307c19d9d1467.1792118040.git.chaosheng.qu.linux@gmail.com

> sun4ican_probe() collapses every failure of platform_get_irq() into
> -ENODEV:
>
>         irq = platform_get_irq(pdev, 0);
>         if (irq < 0) {
>                 err = -ENODEV;
>                 goto exit_put_clk;
>         }
>
> The driver matches through an of_match_table, so of_irq_get() returns
> -EPROBE_DEFER while the interrupt controller has not been probed. The
> probe overwrites it and the driver core stops retrying, leaving the
> device unbound even though the interrupt controller appears later.

[Severity: Low]
Is the quoted pre-patch code accurate? In this tree, the IRQ error path in
sun4ican_probe() does goto exit. There is no exit_put_clk label, and there
is no clk_put() anywhere in drivers/net/can/sun4i_can.c:

exit_free:
	free_candev(dev);
exit:
	return err;

The quote makes it look like the clock is released on this path, but it
is not.

Can the deferral described here happen with the in-tree device trees?
sun4i-a10.dtsi, sun7i-a20.dtsi, sun8i-r40.dtsi and sunxi-d1s-t113.dtsi
route the CAN interrupt to sun4i-ic, the GIC or the D1 PLIC. All of these
register early through IRQCHIP_DECLARE, for example:

IRQCHIP_DECLARE(riscv, "allwinner,sun20i-d1-plic", plic_early_probe);

So the irq domain should already exist by the time this driver probes.

If this is meant as a bug fix, should it carry a Fixes: tag for
0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel
module"), which added the -ENODEV? If it is a robustness and consistency
cleanup instead, could the message say the issue has not been seen on real
hardware, as the sibling commit "can: cc770: don't discard the IRQ lookup
error in probe" does?

> diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
> index af52285d5a4e0..80be48d0593db 100644
> --- a/drivers/net/can/sun4i_can.c
> +++ b/drivers/net/can/sun4i_can.c
> @@ -853,7 +853,7 @@ static int sun4ican_probe(struct platform_device *pdev)
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
> -		err = -ENODEV;
> +		err = irq;
>  		goto exit;
>  	}

[Severity: Medium]
Does this error path leak the clock reference taken by of_clk_get()?

sun4ican_probe() does this just before the IRQ lookup:

	clk = of_clk_get(np, 0);

The goto exit path only returns err, and nothing in the driver calls
clk_put().

Before this patch, an IRQ failure turned into -ENODEV and the probe gave
up, so the reference leaked only once. Now -EPROBE_DEFER from of_irq_get()
is passed through:

of_irq_get()
    domain = irq_find_host(oirq.np);
    if (!domain) {
        rc = -EPROBE_DEFER;
        goto out;
    }

As a result, the device goes on the deferred probe list, and
sun4ican_probe() runs again each time deferred probing is triggered.

Each retry calls of_clk_get()->__of_clk_get()->clk_hw_create_clk(). That
allocates a new struct clk, takes kref_get(&core->ref), and links the
consumer into the clk_core. If the CCU is a module, it also pins the
provider module with try_module_get(). The retry then defers again at
platform_get_irq() and all of these references leak.

The in-tree DTs use early irqchips, but the binding allows any interrupt
parent. One example is interrupts-extended pointing at a GPIO irqchip that
probes late. Would this leak then repeat for as long as the interrupt
parent stays missing?

[Severity: Medium]
The clock lookup just above this hunk discards its error in the same way
the commit message describes for the IRQ lookup:

	clk = of_clk_get(np, 0);
	if (IS_ERR(clk)) {
		dev_err(&pdev->dev, "unable to request clock\n");
		err = -ENODEV;
		goto exit;
	}

The binding (allwinner,sun4i-a10-can.yaml) lists clocks as required.
of_clk_get_hw_from_clkspec() returns -EPROBE_DEFER when the provider has
not registered yet:

	struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);

The clock comes from a sunxi-ng CCU. Those drivers (ccu-sun4i-a10.c,
ccu-sun8i-r40.c, ccu-sun20i-d1.c) are tristate module_platform_driver
drivers, so they can register after the CAN probe. fw_devlink normally
orders this, but not with fw_devlink=off or fw_devlink=permissive.

If the CCU binds late, won't the probe still fail permanently with
-ENODEV before it ever reaches the IRQ lookup fixed here? The reset lookup
and the ioremap already return PTR_ERR(), so this is the only lookup left
that discards the error.

Since the clk leak above needs a respin anyway, could that version also
use err = PTR_ERR(clk), or switch to devm_clk_get()?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118092955.1283165-2-mkl%40pengutronix.de

  reply	other threads:[~2026-11-19  9:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  9:11 [PATCH net-next 0/12] pull-request: can-next 2026-11-18 Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 01/12] MAINTAINERS: add entry for PEAK-System CAN drivers Marc Kleine-Budde
2026-11-18  9:38   ` netdev-bot+sinfo
2026-11-18  9:45     ` Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 02/12] can: raw: remove redundant NULL check before netdev_hold() Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 03/12] can: dev: remove unused safe_candev_priv() Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 04/12] can: convert to DEFINE_SIMPLE_DEV_PM_OPS() Marc Kleine-Budde
2026-11-19  9:54   ` netdev-bot+sashiko
2026-11-18  9:11 ` [PATCH net-next 05/12] can: cc770: don't discard the IRQ lookup error in probe Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 06/12] can: sun4i_can: " Marc Kleine-Budde
2026-11-19  9:54   ` netdev-bot+sashiko [this message]
2026-11-18  9:11 ` [PATCH net-next 07/12] can: at91_can: " Marc Kleine-Budde
2026-11-19  9:54   ` netdev-bot+sashiko
2026-11-18  9:11 ` [PATCH net-next 08/12] can: janz-ican3: " Marc Kleine-Budde
2026-11-19  9:54   ` netdev-bot+sashiko
2026-11-18  9:11 ` [PATCH net-next 09/12] can: ifi_canfd: " Marc Kleine-Budde
2026-11-19  9:54   ` netdev-bot+sashiko
2026-11-18  9:11 ` [PATCH net-next 10/12] can: remove Softing CANcard driver Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 11/12] can: ucan: fix repeated word 'is' in comment Marc Kleine-Budde
2026-11-18  9:11 ` [PATCH net-next 12/12] 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=179508206916.3136.11316421181176601828@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dev.kurt@vandijck-laurijssen.be \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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