🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19076

Re: [PATCH net-next 06/12] can: sun4i_can: don't discard the IRQ lookup error in probe

#19076
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 09:54
151 lines
13510 bytes
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
Technical Details
Message-ID: <179508206916.3136.11316421181176601828@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366917-linux-kernel-netdev=dewy.ru
References: <20261118092955.1283165-7-mkl@pengutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366917-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179508206916.3136.11316421181176601828@kernel.org>
References: <20261118092955.1283165-7-mkl@pengutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2842187"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PIa9HKzUV1zB4zxnvyH4yLAq0cQ= sha256:VQFNW5tt42TNw/L0DnifqYpCsbSq4rh1sJHrfE0Abd8=
	sha1:7Z1Vjeg8HTc6szVZS91600q7N18= sha256:n0tAC43QbD1GtXQPQjz+kPeB4I3Dc0dlTBFmTL6q5PI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E639D1155A8; Thu, 19 Nov 2026 12:54:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 6aeb5HANGlHt;
	Thu, 19 Nov 2026 12:54:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-366917-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 2911C1155A2; Thu, 19 Nov 2026 12:54:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 983347631CD; Thu, 19 Nov 2026 09:54:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795082071;
	b=uQsEb/Qy0SYoZx0JRjNS1fgSQfOsUE5IV2MQ+yU8R3sFa1jTwGylhOzIsLkeE9rccQUU
	 WHeS0Sxh/ltHxhPLSknGDVPLODkMQkIYkvSGkRWdZrrbmiSX5CrPOz8K02+DM2MYNKyCN
	 kmFtX6J9ShncKDbgfvropWz0NiHi2aJaYWgvaau1HAU7IcFRIf66Z4hHsHUCPmFCxMMoK
	 8QgAiEbZNL2IuW9DJgnAd7AaHjzSmrDM7Mu9LrNxo6bmlyEgQGiUfRcm2sY15BdHdVHaP
	 MVVzDPAQUqZpa9ln+26UGDhzT/EAVG5dFgF0mXykp+ZblLBoHaja66o49ekDpboJeFw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795082071;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=ygnSbKp0E7LeTYU5wwx2Ori53L3wjeW4YGehUIRv/YQ=;
	b=KMfPy0oOxe0pDX4zAQ8c3aqo7/6Px+Dx3wFXD54Xy6vJKY0cOsJYcIx+Z6KUG4xQ/sRN
	 xU20e6q8XogNksttwKLw1k94HuJF0o0CTwIZCo9kp5OAZ+RTPVicMcEFxf0zKDmmsAQ15
	 g0W6VteZpLlPo0ByUrsiL+k2MSjJBdYCC/pANt1r6i3jfnAAjdO/w7L/NaKu+cZ1//RlL
	 5k20Q8tq15JnrCNk421kaYFTXzp9WOjjcc/Ld2/24Ghi6rQ7H8BL68/E+GUeFWswBMNZA
	 Kym9zg/xdttXio7ePmxeMac8u1GPU+05yO3Pl2YBwS2e3G84plu4wWRXvOXsg8ezErg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cQo5pdMI;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id F1687606A32A;
	Thu, 19 Nov 2026 09:54:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cQo5pdMI
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795082070;
	b=dSVmwtrjZr2eIXLHuzY7dgQ3XL0qctDvcJ+0wTqLOG6G2XdS75xznz7ISC0/eJcF0T7n
	 YdEtAaPI2wD7qlYEdpRgIoguEOcZiLueTRRi72PnRuHJTSmdp/LnxgM4erFr2ITOHgqLJ
	 IvprnmajKj27AkmcO5SqSjMV6SCAs3AGrRAcOAD+L+RLWb+V5/VS9A5QNjcMJtwzdWgnH
	 QNf3B8EB8mZqDq8Y4RO2poTSxW+wMFPhvjc4fOEzjocqxDbtGatw5lmuuKCls4ccFLybN
	 RhAxP2Vs77o1AUlMfYa8fcOo/nrShTZBj7WYG+rj9iYGJWpbYM7OmtVi4TENJ09B8Ww==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795082070;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=ygnSbKp0E7LeTYU5wwx2Ori53L3wjeW4YGehUIRv/YQ=;
	b=X3rSpwG+i8d1z3KG/1BfMS6WzH9Wz/DQ1bYoCb67DTq5EbRhf++6eGXxWkS6X8YvEEaf
	 kHi/BZ3jujc4hqnGOB0ioXqbSvIsFCXEQc0dK4tI37wF931EdG1X0ujwQARpnFhH5a5vC
	 r3Sln29mg3RsG5R1DmPE0ga5DZ4eZAxhkxQbE/ekZkjs22tmWUkkFBPyDDVad+CGWeZxp
	 DlZSTZoWxU2io7ncWeKGhIWzHU7fxdY0/s59vuITQ6ty8SU5ld2Fzpx8827jnCHU7o/+j
	 kRzoDDjuSDOIWKcPVeRtJ6VXl7VJqzB/WQVKBc6K0pfsov3si8ESl1DCvAEQfvztJ5w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cQo5pdMI;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DB8A606A326;
	Thu, 19 Nov 2026 09:54:30 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 900B91F000C7;
	Thu, 19 Nov 2026 09:54:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795082070;
	bh=ygnSbKp0E7LeTYU5wwx2Ori53L3wjeW4YGehUIRv/YQ=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=cQo5pdMIbXBKoH6WOuy2n2rh2e6aZh5Uy5KgF5sLBA06AUUMMLKPhEG9xCVdRYQb5
	 arRjJ+EGkX4iZUIh40C2Zv1zGB+mlc6IxoPyaiCZi/Hkz15kHW2ZLM4OANlT6iaE0A
	 Jr2Q8Erb1ywg++42hOZuuhHXGouto2BNmlQzItuU7jogBhWL14h3glpNr8VXC2lSCd
	 ny0+a1YQzevjl+3hbFx9jLGjZqicmgQrsywOdRyR4a7mKHu/cloDrEspIHTxIOylV+
	 3XADDzixuaTTvVaRmeFyGzPvcNshYpP/pOrxcgP10TRYz68P0oodJId7CVaBSX8dq7
	 PwItYhfQIgo1w==
X-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
X-In-Reply-To: <20261118092955.1283165-7-mkl@pengutronix.de>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list