From: netdev-bot+sashiko@kernel.org
To: anthony.l.nguyen@intel.com
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, andrew+netdev@lunn.ch,
netdev@vger.kernel.org, tomasz.lichwala@linux.intel.com,
ripatel@wii.dev, xiaolinkui@kylinos.cn, xiaolinkui@126.com,
runyu.xiao@seu.edu.cn, horms@kernel.org,
marcin.szycik@linux.intel.com, przemyslaw.kitszel@intel.com,
rafal.romanowski@intel.com
Subject: Re: [PATCH net 1/4] ixgbe: fix MDIO bus lifetime
Date: Tue, 24 Nov 2026 22:00:56 +0000 [thread overview]
Message-ID: <179555765601.3135.4530614438146845451@kernel.org> (raw)
In-Reply-To: <20261120220022.3133664-2-anthony.l.nguyen@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] The patch now clears adapter->mii_bus only after
unregister_netdev() has returned.
--
ixgbe: fix MDIO bus lifetime
This commit changes ixgbe_mii_bus_init() to register the MDIO bus with
devm_mdiobus_register() on the netdev device. The bus is then unregistered
and freed when unregister_netdev() runs device_del(). The explicit
mdiobus_unregister() calls in the FW error path and in ixgbe_remove() are
dropped, and adapter->mii_bus is now cleared after unregister_netdev() in
both the unsupported SFP path and the FW error path.
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index b9496f0bee131..2b6d1177addab 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -8471,6 +8471,7 @@ static void ixgbe_sfp_detection_subtask(struct ixgbe_adapter *adapter)
> e_dev_err("Reload the driver after installing a "
> "supported module.\n");
> unregister_netdev(adapter->netdev);
> + adapter->mii_bus = NULL;
> }
> }
>
> @@ -8693,11 +8694,8 @@ static void ixgbe_service_task(struct work_struct *work)
> }
> if (ixgbe_check_fw_error(adapter)) {
> if (!test_bit(__IXGBE_DOWN, &adapter->state)) {
> - if (adapter->mii_bus) {
> - mdiobus_unregister(adapter->mii_bus);
> - adapter->mii_bus = NULL;
> - }
> unregister_netdev(adapter->netdev);
> + adapter->mii_bus = NULL;
[Severity: Medium]
With the NULL store moved after unregister_netdev(), does adapter->mii_bus
point at a freed bus for a while?
The bus is now registered via devm on &adapter->netdev->dev in
ixgbe_mii_bus_init(), so unregister_netdev() itself unregisters and frees
it:
unregister_netdev()
unregister_netdevice_many_notify()
netdev_unregister_kobject()
device_del()
devres_release_all()
mdiobus_unregister() + mdiobus_free()
put_device() -> mdiobus_release() -> kfree(bus)
phy_mask is GENMASK(31, 0), so no PHY devices hold extra references. That
means the bus memory really is freed at this point.
Next, unregister_netdev() calls rtnl_unlock() -> netdev_run_todo(). That
function drops RTNL early and then sleeps in rcu_barrier() and
netdev_wait_allrefs_any(). During that whole wait, adapter->mii_bus still
holds the stale pointer and no lock is held.
The old FW error code cleared the pointer before it called
unregister_netdev(). The new hunk in ixgbe_sfp_detection_subtask() has the
same after-the-call ordering.
The reader is ixgbe_mdio_read() (and likewise ixgbe_mdio_write()). It
checks the pointer without a lock and then dereferences it:
if (adapter->mii_bus) {
...
return mdiobus_c45_read(adapter->mii_bus, prtad,
devad, regnum);
return mdiobus_read(adapter->mii_bus, prtad, regnum);
Both calls take bus->mdio_lock, which is inside the freed object.
ixgbe_reset() can get to this reader without RTNL, for example from
ixgbe_io_slot_reset() or ixgbe_resume():
ixgbe_reset()
hw->mac.ops.init_hw / reset_hw
phy.ops.identify -> ixgbe_identify_phy_generic()
ixgbe_probe_phy()
mdio45_probe()
hw->phy.mdio.mdio_read == ixgbe_mdio_read()
Nothing serializes these paths against the service task. The service task
is only cancelled in ixgbe_remove().
This chain only runs when hw->phy.type == ixgbe_phy_unknown. In the trigger
paths traced so far, phy.type was already known, so no concrete
interleaving has been shown. It also hasn't been ruled out for every
MAC/PHY combination.
Would it be safer to clear adapter->mii_bus before calling
unregister_netdev() in both ixgbe_service_task() and
ixgbe_sfp_detection_subtask(), as the old FW error path did?
WRITE_ONCE()/READ_ONCE() or a shared lock around the pointer might also be
worth considering.
> }
> ixgbe_service_event_complete(adapter);
> return;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120220022.3133664-1-anthony.l.nguyen%40intel.com
next prev parent reply other threads:[~2026-11-24 22:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 22:00 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2026-11-20 (ixgbe, ixgbevf, fm10k) Tony Nguyen
2026-11-20 22:00 ` [PATCH net 1/4] ixgbe: fix MDIO bus lifetime Tony Nguyen
2026-11-24 22:00 ` netdev-bot+sashiko [this message]
2026-11-20 22:00 ` [PATCH net 2/4] ixgbe: fix incomplete ACI command buffer backup on retry Tony Nguyen
2026-11-24 22:00 ` netdev-bot+sashiko
2026-11-20 22:00 ` [PATCH net 3/4] ixgbevf: fix link speed reporting for Hyper-V E610 VFs Tony Nguyen
2026-11-24 22:00 ` netdev-bot+sashiko
2026-11-20 22:00 ` [PATCH net 4/4] net: fm10k: shut down the service timer during removal Tony Nguyen
2026-11-24 22:01 ` netdev-bot+sashiko
2026-11-20 22:03 ` [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2026-11-20 (ixgbe, ixgbevf, fm10k) netdev-bot+sinfo
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=179555765601.3135.4530614438146845451@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=marcin.szycik@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rafal.romanowski@intel.com \
--cc=ripatel@wii.dev \
--cc=runyu.xiao@seu.edu.cn \
--cc=tomasz.lichwala@linux.intel.com \
--cc=xiaolinkui@126.com \
--cc=xiaolinkui@kylinos.cn \
/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