From: netdev-bot+sashiko@kernel.org
To: mhun512@gmail.com
Cc: ioana.ciornei@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, ruxandra.radulescu@nxp.com,
gregkh@linuxfoundation.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, ae878000@gmail.com,
stable@vger.kernel.org
Subject: Re: [PATCH net] dpaa2-eth: free the DPNI interrupt before releasing its resources
Date: Mon, 16 Nov 2026 06:59:06 +0000 [thread overview]
Message-ID: <179481234651.3136.10190438261119233878@kernel.org> (raw)
In-Reply-To: <20261112065616.34209-1-mhun512@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 0 (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).
- [High] The patch's new synchronization point, dpaa2_eth_free_irqs() (or
kthread_stop() for the poll thread), still sits after…
Pre-existing issues:
- [High] The dpaa2-switch driver in the same directory still has the
defect this patch fixes in dpaa2-eth.
- [Medium] dpaa2_eth_free_irqs() releases the Linux handler
(devm_free_irq) and returns the MSI vector to the parent DPRC pool…
--
dpaa2-eth: free the DPNI interrupt before releasing its resources
This commit adds dpaa2_eth_free_irqs(). It calls devm_free_irq() on the
DPNI interrupt before fsl_mc_free_irqs(). The helper is used in
dpaa2_eth_remove() and in the dpaa2_eth_probe() error path, so the handler
is released and synchronized before the MAC is disconnected and the portal
and net device are freed.
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> index 7227a35dfaf2f..91462b88b34ad 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> @@ -4824,6 +4824,14 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev)
> return err;
> }
>
> +static void dpaa2_eth_free_irqs(struct fsl_mc_device *ls_dev)
> +{
> + struct fsl_mc_device_irq *irq = ls_dev->irqs[0];
> +
> + devm_free_irq(&ls_dev->dev, irq->virq, &ls_dev->dev);
> + fsl_mc_free_irqs(ls_dev);
[Severity: Medium]
This isn't a bug introduced by this patch, but should this helper also
disable the DPNI interrupt in the MC before the vector is given back?
dpaa2_eth_setup_irqs() arms it:
err = dpni_set_irq_enable(ls_dev->mc_io, 0, ls_dev->mc_handle,
DPNI_IRQ_INDEX, 1);
Nothing in dpaa2-eth ever calls dpni_set_irq_enable(..., 0). On the free
path, __fsl_mc_msi_write_msg() also returns early without unprogramming the
MSI:
if (msi_desc->msg.address_lo == 0x0 && msi_desc->msg.address_hi == 0x0)
return;
Once fsl_mc_free_irqs() returns the vector to the DPRC pool, another object
in the same container could be given that vector. Suppose a DPNI link or
endpoint change happens before dpaa2_eth_free_dpni()->dpni_reset(), or at
any later time if the reset doesn't clear the enable. The DPNI could then
send a stale MSI to the new owner's handler, and nothing would clear the
DPNI IRQ status.
This depends on MC firmware behavior that can't be confirmed from the
kernel source.
The peer teardown paths disable the interrupt at the object first.
dprc_teardown_irq() does:
(void)disable_dprc_irq(mc_dev);
devm_free_irq(&mc_dev->dev, irq->virq, &mc_dev->dev);
fsl_mc_free_irqs(mc_dev);
dpaa2_switch_teardown_irqs() also calls dpsw_set_irq_enable(..., 0) before
fsl_mc_free_irqs().
Would a dpni_set_irq_enable(..., 0) call ahead of devm_free_irq() fit in
this helper?
[Severity: High]
This isn't a bug introduced by this patch, but dpaa2-switch.c in the same
directory seems to have the same problem that this patch fixes in
dpaa2-eth.
dpaa2_switch_setup_irqs() registers dpaa2_switch_irq0_handler_thread()
with devm_request_threaded_irq(). The teardown helper does only this:
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c:dpaa2_switch_teardown_irqs() {
err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle,
DPSW_IRQ_INDEX_IF, 0);
...
fsl_mc_free_irqs(sw_dev);
}
There is no devm_free_irq() call. dpaa2_switch_remove() then frees the
port netdevs and port_priv, ethsw->ports, ethsw->lags, the MC portal and
ethsw. The handler stays registered until devres runs, after remove()
returns.
Disabling the interrupt in the MC stops new interrupts. It doesn't wait
for a handler thread that is already running, and that thread does:
port_priv = ethsw->ports[if_id];
if (status & DPSW_IRQ_EVENT_LINK_CHANGED)
dpaa2_switch_port_link_state_update(port_priv->netdev);
It later calls dpsw_clear_irq_status(ethsw->mc_io, ...).
Can these accesses hit freed memory? The dpaa2_switch_probe() error path
at err_unregister_ports uses the same helper.
The error path inside dpaa2_switch_setup_irqs() already pairs
devm_free_irq() with fsl_mc_free_irqs(). Should dpaa2-switch get the same
fix, perhaps as a follow-up patch?
dpaa2-ptp doesn't have this problem. It uses request_threaded_irq(), and
dpaa2_ptp_remove() calls ptp_qoriq_free(), which reaches free_irq(), before
fsl_mc_free_irqs().
> +}
> +
> static void dpaa2_eth_add_ch_napi(struct dpaa2_eth_priv *priv)
> {
> int i;
[ ... ]
> @@ -5104,7 +5112,7 @@ static void dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
> if (priv->do_link_poll)
> kthread_stop(priv->poll_thread);
> else
> - fsl_mc_free_irqs(ls_dev);
> + dpaa2_eth_free_irqs(ls_dev);
[Severity: High]
Does this synchronization happen early enough? In dpaa2_eth_remove() it
still runs after unregister_netdev():
unregister_netdev(net_dev);
dpaa2_eth_dl_port_del(priv);
dpaa2_eth_dl_traps_unregister(priv);
dpaa2_eth_dl_free(priv);
if (priv->do_link_poll)
kthread_stop(priv->poll_thread);
else
dpaa2_eth_free_irqs(ls_dev);
The commit message says a link or endpoint change can "access the freed MC
portal and net device". A link-up handler that overlaps with
unregister_netdev() still seems able to do that.
One possible sequence:
dpni_irq0_handler_thread()
dpaa2_eth_link_state_update()
dpni_get_link_state() -> state.up = 1
dpaa2_eth_set_rx_taildrop() (MC commands, may sleep)
dpaa2_eth_remove()
unregister_netdev()
dpaa2_eth_stop()
netif_carrier_off()
linkwatch_forget_dev()
reg_state = NETREG_UNREGISTERED
netif_carrier_on(priv->net_dev)
linkwatch_fire_event()
linkwatch_add_event()
netdev_hold(), dev added to lweventlist
dpaa2_eth_free_irqs() (thread already done)
...
free_netdev(net_dev)
netif_carrier_on() returns early only for NETREG_UNINITIALIZED:
if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
if (dev->reg_state == NETREG_UNINITIALIZED)
return;
atomic_inc(&dev->carrier_up_count);
linkwatch_fire_event(dev);
So the unregistered device still gets queued on lweventlist. Could the
linkwatch work then run linkwatch_do_dev() and netdev_put() on the
net_device after free_netdev()?
dpaa2_eth_link_state_update() and the unregister/stop path don't share a
lock. dpaa2_eth_poll_link_state() is also stopped only at this point, so
the poll thread has the same window.
Would it be better to quiesce the DPNI interrupt, or stop the poll thread,
before unregister_netdev()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112065616.34209-1-mhun512%40gmail.com
prev parent reply other threads:[~2026-11-16 6:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 6:56 Myeonghun Pak
2026-11-16 6:59 ` 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=179481234651.3136.10190438261119233878@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ae878000@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhun512@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ruxandra.radulescu@nxp.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®