From: netdev-bot+sashiko@kernel.org
To: magnusleatti@kernelriot.com
Cc: me@ziyao.cc, maxime.chevallier@bootlin.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, g.nespolino@gmail.com,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: stmmac: dwmac-motorcomm: remove the device at shutdown
Date: Tue, 24 Nov 2026 10:57:44 +0000 [thread overview]
Message-ID: <179551786477.3135.6652175828683602957@kernel.org> (raw)
In-Reply-To: <20261120102754.778283-2-magnusleatti@kernelriot.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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 wires `.shutdown` to the full driver teardown:
`motorcomm_remove()`, which calls `stmmac_dvr_remove()`.
- [Low] The commit message describes a defect: without .shutdown, reboot,
kexec and power-off leave the MAC and DMA running.
--
net: stmmac: dwmac-motorcomm: remove the device at shutdown
This commit sets the .shutdown callback of the Motorcomm YT6801 PCI glue
driver to motorcomm_remove(). As a result, stmmac_dvr_remove() runs on
reboot, kexec and power-off, so the interface is closed and the DMA and
MAC are stopped before the next kernel or power state.
> No .shutdown here, so reboot, kexec and power-off leave the MAC and
> DMA running. This chip keeps its registers through S5 too.
[Severity: Low]
Should this carry a Fixes: tag?
The problem described here is real for kexec. motorcomm_probe() calls
pci_set_master() before motorcomm_reset(), and pci_device_shutdown()
only clears bus mastering without resetting the DMA engine.
The dwmac_motorcomm_pci_driver struct without a .shutdown callback
came in with:
Fixes: 02ff155ea281 ("net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller")
Without the tag, stable trees that carry this driver won't pick up
the change. A backport of this patch as written would also bring in
the double teardown described below.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> index 42f0b11a7b606..63ce2301a0f69 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
> @@ -374,6 +374,7 @@ static struct pci_driver dwmac_motorcomm_pci_driver = {
> .id_table = dwmac_motorcomm_pci_id_table,
> .probe = motorcomm_probe,
> .remove = motorcomm_remove,
> + .shutdown = motorcomm_remove,
[Severity: Medium]
With this change, can stmmac_dvr_remove() run twice on the same
binding?
device_shutdown()->pci_device_shutdown() only calls drv->shutdown().
It does not unbind the driver. device_lock(dev) is released as soon
as the callback returns, and drvdata still points to the
devm-allocated net_device.
The device is still bound, so a later .remove can still happen.
Examples are a sysfs unbind, rmmod, or a pciehp/Thunderbolt surprise
removal handled by the parent port. The parent port is shut down
after its children, because device_shutdown() walks the device list
backwards. Any of these goes through:
pci_device_remove()
motorcomm_remove()
stmmac_dvr_remove()
unregister_netdev(ndev)
stmmac_dvr_remove() is not safe to call twice:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_dvr_remove() {
...
unregister_netdev(ndev);
...
phylink_destroy(priv->phylink);
...
destroy_workqueue(priv->wq);
mutex_destroy(&priv->lock);
mutex_destroy(&priv->est_lock);
bitmap_free(priv->af_xdp_zc_qps);
...
}
It clears none of these pointers and sets no flag to record that
teardown has already happened. On the second call,
unregister_netdevice_many_notify() would hit this with rtnl_mutex
held:
BUG_ON(dev->reg_state != NETREG_REGISTERED);
With CONFIG_BUG=n, the second call would instead lead to:
- a use-after-free and double free of the phylink in
phylink_destroy()
- a use-after-free in destroy_workqueue()
- a double bitmap_free()
The follow-up patch "net: stmmac: dwmac-motorcomm: support Wake-on-LAN
from S5" still calls stmmac_dvr_remove() unconditionally from
motorcomm_shutdown(). The problem is therefore still present at the
end of the series.
For comparison, the shutdown hook in dwmac-sun8i only quiesces the
hardware. Could this driver use a shutdown that only quiesces the
device instead? That would mean detaching and closing the interface
under rtnl, stopping DMA and MAC, and powering down or arming the
PHY. Another option would be to make the remove path safe to call
twice.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120102754.778283-1-magnusleatti%40kernelriot.com
next prev parent reply other threads:[~2026-11-24 10:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:27 [PATCH net-next v2 0/2] net: stmmac: dwmac-motorcomm: shutdown hook and Wake-on-LAN from S5 Magnus Leatti
2026-11-20 10:27 ` [PATCH net-next v2 1/2] net: stmmac: dwmac-motorcomm: remove the device at shutdown Magnus Leatti
2026-11-24 10:57 ` netdev-bot+sashiko [this message]
2026-11-20 10:27 ` [PATCH net-next v2 2/2] net: stmmac: dwmac-motorcomm: support Wake-on-LAN from S5 Magnus Leatti
2026-11-24 10:57 ` 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=179551786477.3135.6652175828683602957@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=g.nespolino@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=magnusleatti@kernelriot.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=me@ziyao.cc \
--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