Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: 18255117159@163.com
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
Subject: Re: [PATCH 4/4] net: use dev_err_probe() for MDIO bus registration errors
Date: Tue, 01 Dec 2026 02:46:34 +0000	[thread overview]
Message-ID: <179609319455.3146.5862482102202898960@kernel.org> (raw)
In-Reply-To: <20261130023745.820141-5-18255117159@163.com>

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

      reply	other threads:[~2026-12-01  2:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  2:37 [PATCH 0/4] prepare MDIO callers for -EPROBE_DEFER from __mdiobus_register() Hans Zhang
2026-11-30  2:37 ` [PATCH 1/4] net: ethernet: lantiq_etop: propagate mdiobus_register() errors Hans Zhang
2026-12-01  2:46   ` netdev-bot+sashiko
2026-11-30  2:37 ` [PATCH 2/4] net: ethernet: smsc911x: " Hans Zhang
2026-12-01  2:46   ` netdev-bot+sashiko
2026-11-30  2:37 ` [PATCH 3/4] net: ethernet: smsc9420: " Hans Zhang
2026-12-01  2:46   ` netdev-bot+sashiko
2026-11-30  2:37 ` [PATCH 4/4] net: use dev_err_probe() for MDIO bus registration errors Hans Zhang
2026-12-01  2:46   ` netdev-bot+sashiko [this message]

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=179609319455.3146.5862482102202898960@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=18255117159@163.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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