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 3/4] net: ethernet: smsc9420: propagate mdiobus_register() errors
Date: Tue, 01 Dec 2026 02:46:32 +0000 [thread overview]
Message-ID: <179609319291.3146.16107243352034165029@kernel.org> (raw)
In-Reply-To: <20261130023745.820141-4-18255117159@163.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 2 · 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] In smsc9420_mii_init(), the patch stores the result of
mdiobus_register() in `err`.
- [High] The commit message says that propagating the mdiobus_register()
error, especially -EPROBE_DEFER, lets 'the driver defer correctly when…
--
net: ethernet: smsc9420: propagate mdiobus_register() errors
The patch changes smsc9420_mii_init() to store the return value of
mdiobus_register() in err. Registration errors such as -EPROBE_DEFER are
then returned instead of the default -ENXIO.
> mdiobus_register() can return -EPROBE_DEFER. Return that error instead
> of converting every failure to the initial -ENXIO so the driver can
> defer correctly when probed from async context.
[Severity: High]
Is this description accurate for this driver?
smsc9420_mii_init() is not called from smsc9420_probe(). Its only caller
is smsc9420_open(), the ndo_open handler. That caller replaces any
non-zero return with -ENODEV:
drivers/net/ethernet/smsc/smsc9420.c:smsc9420_open() {
...
result = smsc9420_mii_init(dev);
if (result) {
netif_warn(pd, ifup, pd->dev, "Failed to initialize Phy\n");
result = -ENODEV;
goto out_free_rx_ring_3;
}
...
}
So the propagated error is thrown away. Even if it were passed through,
-EPROBE_DEFER returned from ndo_open would reach userspace as errno 517.
It would not trigger a deferred probe, because deferral only applies to
errors returned from a .probe callback.
Also, the only -EPROBE_DEFER source in __mdiobus_register() seems to be
the optional reset GPIO lookup, devm_gpiod_get_optional(&bus->dev,
"reset", ...). This driver never sets a parent or fwnode on its bus.
Should this change be dropped? Alternatively, the MDIO bus setup could
move into smsc9420_probe(), with the commit message updated to match.
> diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
> index 0c97211b6254e..6b563b0c7cb06 100644
> --- a/drivers/net/ethernet/smsc/smsc9420.c
> +++ b/drivers/net/ethernet/smsc/smsc9420.c
> @@ -1153,7 +1153,8 @@ static int smsc9420_mii_init(struct net_device *dev)
> /* Mask all PHYs except ID 1 (internal) */
> pd->mii_bus->phy_mask = ~(1 << 1);
>
> - if (mdiobus_register(pd->mii_bus)) {
> + err = mdiobus_register(pd->mii_bus);
> + if (err) {
> netif_warn(pd, probe, pd->dev, "Error registering mii bus\n");
> goto err_out_free_bus_2;
> }
[Severity: High]
When mdiobus_register() succeeds, err is now 0. Does the next failure
branch still return an error?
drivers/net/ethernet/smsc/smsc9420.c:smsc9420_mii_init() {
...
if (smsc9420_mii_probe(dev) < 0) {
netif_warn(pd, probe, pd->dev, "Error probing mii bus\n");
goto err_out_unregister_bus_3;
}
return 0;
err_out_unregister_bus_3:
mdiobus_unregister(pd->mii_bus);
err_out_free_bus_2:
mdiobus_free(pd->mii_bus);
err_out_1:
return err;
}
Before this patch, err was still -ENXIO at this point. Now
smsc9420_mii_probe() can fail because no PHY is found at address 1, or
because phy_connect() fails. In that case the bus is unregistered and
freed, but smsc9420_mii_init() returns 0.
smsc9420_open() then treats this as success and calls:
phy_start(dev->phydev);
dev->phydev is still NULL at that point, because only a successful
phy_connect() in smsc9420_mii_probe() sets it. phy_start() calls
mutex_lock(&phydev->lock) without a NULL check. Can this oops while RTNL
is held?
pd->mii_bus is also left pointing at freed memory. Later, smsc9420_stop()
would hit BUG_ON(!dev->phydev). After that, it would call
mdiobus_unregister() and mdiobus_free() on the bus that was already
freed.
Would something like this restore the previous behaviour?
err = smsc9420_mii_probe(dev);
if (err < 0) {
netif_warn(pd, probe, pd->dev, "Error probing mii bus\n");
goto err_out_unregister_bus_3;
}
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130023745.820141-1-18255117159%40163.com
next prev parent 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 [this message]
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=179609319291.3146.16107243352034165029@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