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 1/4] net: ethernet: lantiq_etop: propagate mdiobus_register() errors
Date: Tue, 01 Dec 2026 02:46:29 +0000	[thread overview]
Message-ID: <179609318984.3146.12786132029140913678@kernel.org> (raw)
In-Reply-To: <20261130023745.820141-2-18255117159@163.com>

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

Critical: 0 · High: 1 (1) · Medium: 0 · Low: 0

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] The patch cannot achieve what its commit message says it does.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the error path
  the patch changes ends in a self-deadlock, and the code behind the…

--

net: ethernet: lantiq_etop: propagate mdiobus_register() errors

This commit changes ltq_etop_mdio_init() so that it returns the error from
mdiobus_register() as is, instead of turning every failure into -ENXIO.
The stated goal is to let the driver defer its probe when
mdiobus_register() returns -EPROBE_DEFER.

> diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
> index 83ce3bfefa5c2..8c64687c3fd85 100644
> --- a/drivers/net/ethernet/lantiq_etop.c
> +++ b/drivers/net/ethernet/lantiq_etop.c
> @@ -400,10 +400,9 @@ ltq_etop_mdio_init(struct net_device *dev)
>  	priv->mii_bus->name = "ltq_mii";
>  	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
>  		 priv->pdev->name, priv->pdev->id);
> -	if (mdiobus_register(priv->mii_bus)) {
> -		err = -ENXIO;
> +	err = mdiobus_register(priv->mii_bus);
> +	if (err)
>  		goto err_out_free_mdiobus;
> -	}

[Severity: High]
Can this driver actually defer its probe? The commit message says this is
"so the driver can defer correctly when probed from async context". But
init_ltq_etop() binds the driver through platform_driver_probe():

init_ltq_etop()
    int ret = platform_driver_probe(&ltq_mii_driver, ltq_etop_probe);

Also, ltq_etop_probe() is marked __init.

__platform_driver_probe() rejects PROBE_PREFER_ASYNCHRONOUS and forces
PROBE_FORCE_SYNCHRONOUS. It also sets:

    drv->prevent_deferred_probe = true;

platform_probe() then rewrites the error:

    if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
        dev_warn(_dev, "probe deferral not supported\n");
        ret = -ENXIO;
    }

So -EPROBE_DEFER from mdiobus_register() travels
ltq_etop_mdio_init() -> ltq_etop_init() -> register_netdev() ->
ltq_etop_probe() -> platform_probe() and still ends up as -ENXIO, as it
did before. The only difference is the new warning.

The device is never added to the deferred probe list. A retry could not
run anyway, because the __init probe is discarded after boot.

Is the only real change that other mdiobus_register() errors, such as
-ENOMEM or -EINVAL, now reach the caller unchanged? If deferral is the
goal, the driver would need platform_driver_register() with a non-__init
probe, plus a fixed ndo_init unwind (see below). If not, could the commit
message describe what actually changes?

The later patch in this series, "net: use dev_err_probe() for MDIO bus
registration errors", does not touch lantiq_etop.c, so this is still the
case at the end of the series.

The other failure path in the same function still overrides its error:

>  
>  	if (ltq_etop_mdio_probe(dev)) {
>  		err = -ENXIO;

ltq_etop_mdio_probe() can return -ENODEV or PTR_ERR(phy_connect()), and
both are still replaced with -ENXIO. Is that difference intended?

[Severity: High]
This is a pre-existing issue that this patch did not introduce. What
happens in ltq_etop_init() when the error passed up from here reaches it?

ltq_etop_init() is the ndo_init callback, so it runs under RTNL:

ltq_etop_probe()
  register_netdev()
    rtnl_net_lock_killable()
    register_netdevice()
      ltq_etop_init()

If ltq_etop_mdio_init() or ltq_etop_set_mac_address() fails, it unwinds
with:

drivers/net/ethernet/lantiq_etop.c:ltq_etop_init() {
    ...
err_netdev:
	unregister_netdev(dev);
	free_netdev(dev);
err_hw:
	ltq_etop_hw_exit(dev);
	return err;
}

Won't unregister_netdev() take rtnl_mutex again, via rtnl_net_dev_lock()
-> rtnl_net_lock() -> rtnl_lock(), while this task already holds it? That
would hang the probe thread while it holds RTNL.

Even if that deadlock did not happen, free_netdev() frees dev and its priv
area. ltq_etop_hw_exit(dev) would then walk priv->ch[] in freed memory.

ltq_etop_probe() would then free the netdev a second time on its err_free
path:

	err = register_netdev(dev);
	if (err)
		goto err_free;
	...
err_free:
	free_netdev(dev);

Should ndo_init only undo what it set up itself, and leave freeing the
netdev to the caller? This path can be reached if no PHY is found on the
bus, if phy_connect() fails, or if mdiobus_register() fails.

-- 
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 [this message]
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

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=179609318984.3146.12786132029140913678@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