🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24917

Re: [PATCH 4/4] net: use dev_err_probe() for MDIO bus registration errors

#24917
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 02:46
207 lines
15264 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

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

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).

- [High] Eight converted call sites pass the net_device's embedded struct
  device to dev_err_probe(): &netdev->dev, &ndev->dev, &tc6->netdev->dev…
- [Medium] The commit message says these callers already propagate
  -EPROBE_DEFER, and that is the reason it gives for demoting the…
- [Low] The commit message calls the conversion 'mechanical' and says it
  only suppresses messages for deferred probes.
- [Low] In thunder_mdiobus_pci_probe() the converted
  dev_err_probe(&pdev->dev, err, ...) allocates a deferred_probe_reason…

--

net: use dev_err_probe() for MDIO bus registration errors

This converts the MDIO bus registration error messages in a number of
networking drivers from dev_err(), netdev_err() and dev_warn() to
dev_err_probe(). The goal is to suppress the message when registration
returns -EPROBE_DEFER. The return paths are meant to stay the same.

> diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> index 9eed0be4411e4..0c72b137c6148 100644
> --- a/drivers/net/ethernet/altera/altera_tse_main.c
> +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> @@ -157,8 +157,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
>
>  	ret = of_mdiobus_register(mdio, mdio_node);
>  	if (ret != 0) {
> -		netdev_err(dev, "Cannot register MDIO bus %s\n",
> -			   mdio->id);
> +		dev_err_probe(&dev->dev, ret, "Cannot register MDIO bus %s\n",
> +			      mdio->id);

[Severity: High]

Is &dev->dev safe to pass to dev_err_probe() at this point?

altera_tse_probe() reaches altera_tse_mdio_create() through
altera_tse_phy_get_addr_mdio_create(), before register_netdev() is
called. The net_device's embedded struct device only goes through
device_initialize() and device_add() in netdev_register_kobject(), so
dev->dev.p is still NULL here.

of_mdiobus_register() can return -EPROBE_DEFER. One way is the reset
GPIO lookup in __mdiobus_register(). Another is
fwnode_mdiobus_phy_device_register() when the PHY interrupt provider
hasn't probed yet. In that case the call chain is:

dev_err_probe()
  __dev_probe_failed()
    device_set_deferred_probe_reason()
      mutex_lock(&deferred_probe_mutex);
      __device_set_deferred_probe_reason()
        kfree(dev->p->deferred_probe_reason);

Can this dereference the NULL dev->p while the global
deferred_probe_mutex is held? If so, the mutex is never released, and
every later deferred probe on the system would block on it.

The old netdev_err() only printed and never touched dev->p.

These other converted sites use the same pattern, and all of them run
before the net_device is registered:

  ethoc_probe(): &netdev->dev
  oa_tc6_mdiobus_register(): &tc6->netdev->dev, reached through
    oa_tc6_init() from the lan865x and adin1140 probe paths
  sxgbe_mdio_register(): &ndev->dev
  ax88772_init_mdio(), ax88172a_init_mdio(), lan78xx_mdio_init(),
    smsc95xx_bind(): &dev->net->dev, called from the usbnet bind
    callback before register_netdev() in usbnet_probe()

The USB drivers would hit this on hot-plug.

Would it work to pass the parent or bus device at these sites, for
example &pdev->dev, &spi->dev, &intf->dev or dev->net->dev.parent? The
other option is to keep netdev_err() there.

>  		goto out_free_mdio;
>  	}
>  	of_node_put(mdio_node);
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 95827df4cf6a1..09dbeb6d29db1 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -1557,7 +1557,7 @@ static int tg3_mdio_init(struct tg3 *tp)
>
>  	i = mdiobus_register(tp->mdio_bus);
>  	if (i) {
> -		dev_warn(&tp->pdev->dev, "mdiobus_reg failed (0x%x)\n", i);
> +		dev_err_probe(&tp->pdev->dev, i, "mdiobus_reg failed\n");

[Severity: Low]

This isn't a bug, but the commit message says:

  Convert the networking callers to dev_err_probe() so the message is
  suppressed for deferred probes.  This is a mechanical change and does
  not alter the return path.

In tg3_mdio_init() the log level goes up from dev_warn to dev_err. The
"(0x%x)" errno output is also replaced by the "error %pe:" prefix from
__dev_probe_failed().

__dev_probe_failed() also prints nothing for -ENOMEM:

	case -ENOMEM:
		/* Don't print anything on -ENOMEM, there's already enough output */
		break;

That makes -ENOMEM failures from MDIO registration silent at all the
converted sites, not only -EPROBE_DEFER.

Could the commit message mention these changes?

>  		mdiobus_free(tp->mdio_bus);
>  		return i;
>  	}

[ ... ]

> diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
> index aea067658de2d..a77381f84e871 100644
> --- a/drivers/net/mdio/mdio-thunder.c
> +++ b/drivers/net/mdio/mdio-thunder.c
> @@ -99,7 +99,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
>
>  		err = of_mdiobus_register(bus->mii_bus, node);
>  		if (err)
> -			dev_err(&pdev->dev, "of_mdiobus_register failed\n");
> +			dev_err_probe(&pdev->dev, err, "of_mdiobus_register failed\n");

[Severity: Medium]

The commit message says:

  When __mdiobus_register() returns -EPROBE_DEFER, these
  callers already propagate the error

Does that hold for thunder_mdiobus_pci_probe()? The error from
of_mdiobus_register() is dropped here. The loop continues and the probe
returns 0:

		err = of_mdiobus_register(bus->mii_bus, node);
		if (err)
			dev_err_probe(&pdev->dev, err, ...);
		...
	}
	return 0;

On -EPROBE_DEFER, dev_err_probe() now only logs at dev_dbg() level, but
the bus is never retried. The failure is silent at default log levels,
where the old dev_err() printed it.

altera_tse_mdio_create() has a similar problem. Its caller,
altera_tse_phy_get_addr_mdio_create(), does this:

	ret = altera_tse_mdio_create(dev,
				     atomic_add_return(1, &instance_count));

	if (ret)
		return -ENODEV;

so -EPROBE_DEFER turns into a permanent -ENODEV probe failure, and the
message that explained it is now hidden.

[Severity: Low]

Does this also leak the deferred probe reason string for pdev->dev?

On -EPROBE_DEFER, dev_err_probe() calls
device_set_deferred_probe_reason(), which allocates
dev->p->deferred_probe_reason with kasprintf().

thunder_mdiobus_pci_probe() then returns 0, so the device is never put
on the deferred list. That means driver_deferred_probe_del() never
clears the reason:

	if (!list_empty(&dev->p->deferred_probe)) {
		dev_dbg(dev, "Removed from deferred list\n");
		list_del_init(&dev->p->deferred_probe);
		__device_set_deferred_probe_reason(dev, NULL);
	}

device_release() later frees dev->p with kfree(p) without freeing
p->deferred_probe_reason.

The old dev_err() didn't allocate anything.

>
>  		dev_info(&pdev->dev, "Added bus at %llx\n", r.start);
>  		if (i >= ARRAY_SIZE(nexus->buses))

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130023745.820141-1-18255117159%40163.com
Technical Details
Message-ID: <179609319455.3146.5862482102202898960@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374642-linux-kernel-netdev=dewy.ru
References: <20261130023745.820141-5-18255117159@163.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374642-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 4/4] net: use dev_err_probe() for MDIO bus registration errors
Date: Tue, 01 Dec 2026 02:46:34 +0000
Organization: Usenet Network
Message-ID: <179609319455.3146.5862482102202898960@kernel.org>
References: <20261130023745.820141-5-18255117159@163.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1594150"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cJ6Gdq7M/g1TW6BVDV5dol8X1wc= sha256:mHS6I37YGxlvVbn8qsO9oqVbr2rQKQat8DkRJmLFv90=
	sha1:wJTCPrgbzTkvnq/GfY/Tv8q2AY8= sha256:/CkebPN8HsWiRxdrpMj98Aoggq2jo6TU639IJbNxhHw=
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 CA3B6C9997; Tue,  1 Dec 2026 05:46:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 L_npX-mpTVyB;
	Tue,  1 Dec 2026 05:46:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374642-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 53098117203; Tue,  1 Dec 2026 05:46:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 09E852949E; Tue,  1 Dec 2026 02:46:37 +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=1796093196;
	b=qAQaTTDYrawVkIou52uOAbwuhFfsdXuo9UZQ1SJIDkaifUJIvXd65Oan+lbMfmCJf9uW
	 gsHYo6uea00uTQQcLJmBLw8V6kGQ7CzDxgZ1nSDg4Jc0pdCDNyQ0yBSZHhhYpOA1nkapQ
	 cax/q0GQ6fCyoMQqc7wjsui6UGHH1igXsWGmSg+v/YRB1VVUGoygOwYoOtYPfFmnDi60r
	 XVSUQhr33qXiz2pnSRBvePR72Zhe+doH+hmS8nUJ5N5YGT2JrbvGR9CDjxLp6lm7luQRP
	 StQW+0VfZq68+0Mt6g2/BWtqzgBLbDMPMAWGyfSlVQCzl+gDno2ltCQU1zdFOBVa71g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796093196;
	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=bJ5xhCwbVp5+5IOFkSNp4yrhLMuu2cmCPnbpOq05+I0=;
	b=RFVhvrJ3bEnLFbpn2W7s8vVF1aeEQhuup3rWLB/oJLyb34u/3j0VK0L39buWx39E3SX3
	 mh17ugZrSVYwZoi52KTnQPODAWsuw1pDfZTr0NiJxz+ljXn2vCokma03bxfrB0lpUxF+S
	 eWJj+smBPBSOYflK+rW3Ff+xtDpPj3ObSr+wNclkszC/5CpkLUBFtBv3MVriwTiwiKnqz
	 gQQprUr8J4a0xQn8ILxFUrt/pznIljPjuuazVBGP0niJ+7H0uUSN+wFALlR+GONlOgsd/
	 +ycP5v8jHQqA46QY32M3Av9X3yBxI7jPK+rANvGbEpPHmK2NS+Lzt4Jch8pQOARDeCA==
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=C3ht4Eyg;
	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 D714C606A320;
	Tue,  1 Dec 2026 02:46:36 +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=C3ht4Eyg
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=1796093196;
	b=Q1pSN+FXAOSHOD0kKrViBTirrIhlVRpSE58Us/kyb6Dj/qQATLosecEXK/KmYT4jJm2v
	 KLeLngi0wEvgsOb7vl97SuMv/VzjJcEHVEawrQQEaCJdC2CR9+qJ0EteQoDXfBvJcC5H6
	 +NvAfxJPs3gWwHtBjdxpFX5x96bamgjYZcKP0r2ijYvfwtFB1hTtBFn0bPwKeDQBVeLGR
	 LDKLTPV4PKOju0JstWZusL+Y/OytlijArPkpAa0JohVNAorpURXvzSKQ/y0aCQ4JeZMTU
	 0NqIhenDzo2p1dCTgPL0CS2sQOHpustsOBH17yZdKjdsQ84gzJ+N0odupXjYXn4krPA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796093196;
	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=bJ5xhCwbVp5+5IOFkSNp4yrhLMuu2cmCPnbpOq05+I0=;
	b=PxOzlLcmzQMgPlSK5yIKccvHunb5FFMTeUOo3IKmpJaiMfC/uERQAdvwO5g4yZthUdj2
	 kpB2xP3ZemzfAVwxGnqy+0R4B1cRlL76TajFe7crsmboYVm1o4FBT/WnhJHRm12OTtKOE
	 yKYMxOCIqX2li4JESfCOiXPBpYc47wZRKqq2FikLysibwJD0vrprjiVv9srWIcCvjHxYG
	 26JJOMpVOv+seldj5tw1Efp05RpcgLcGlZNpLI6NbASvUFvZ912R976JAmo/h1fkGZdZm
	 TKUZ6l/UftS1Xhhs8zWVFH8VajROaqe4caIxI1YJmTwOsB/Nr/plWkpnReFnu7Rdvbw==
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=C3ht4Eyg;
	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 F3BAD606A32E
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 02:46:35 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 093FC1F00899;
	Tue,  1 Dec 2026 02:46:34 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796093195;
	bh=bJ5xhCwbVp5+5IOFkSNp4yrhLMuu2cmCPnbpOq05+I0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=C3ht4EygoJKIiQ7g5AZCEmTbJtXiXKdvNnYrJrjL39jlIgdQntwKhT39H7HhTbRP3
	 FcSYbXfJeOisCd2/WCiR0G3tqHv7MBruJc/0a+Lgh/C1UoRbT26fA04WyB4woIdm7p
	 9S65xQpBQKQWjPxAt0Gz+F8oSKYVp7rW9kqdq53N9JTP4hqhyI/G4BPZ6McTBDHirM
	 rktrMl7jIogdj0Dh9FrAqMC4Bo2ceqPV078ywcEunfpabM0qlBauViYWsTWuABvh7A
	 XPfl9aY0Cq7QvX1ygzaUcMxMnh/4W435pqmNcHyMA0qFDIrmNGK+TdxcilvHsscTWr
	 xL9BQfwEKpBjQ==
X-Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 linux@armlinux.org.uk, netdev@vger.kernel.org
X-In-Reply-To: <20261130023745.820141-5-18255117159@163.com>
X-sashiko-severity: High
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