From: sashiko-bot@kernel.org
To: "Daniel Machon" <daniel.machon@microchip.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v4 08/13] net: lan966x: add shutdown callback to stop FDMA on reboot
Date: Sat, 09 May 2026 08:27:19 +0000 [thread overview]
Message-ID: <20260509082719.94D72C2BCB4@smtp.kernel.org> (raw)
In-Reply-To: <20260508-lan966x-pci-fdma-v4-8-14e0c89d8d63@microchip.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] NULL Pointer Dereference in `lan966x_shutdown` due to uninitialized NAPI structure.
- [High] Unsafe Teardown: Network Queues Reactivate DMA Engine across host reboot.
--
commit 416539af976fe45bd91d93198a7588ced579e467
Author: Daniel Machon <daniel.machon@microchip.com>
net: lan966x: add shutdown callback to stop FDMA on reboot
When lan966x is used as a PCIe endpoint, the FDMA engine runs on the
card and survives a host reboot. Without a shutdown callback, channels
stay active and interrupt sources stay armed across the reset.
[ ... ]
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> index b3701953b0905..271c023900dbe 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> @@ -1311,9 +1311,27 @@ static void lan966x_remove(struct platform_device *pdev)
> debugfs_remove_recursive(lan966x->debugfs_root);
> }
>
> +static void lan966x_shutdown(struct platform_device *pdev)
> +{
> + struct lan966x *lan966x = platform_get_drvdata(pdev);
> +
> + if (!lan966x->fdma)
> + return;
> +
> + lan966x_fdma_rx_disable(&lan966x->rx);
> + lan966x_fdma_tx_disable(&lan966x->tx);
Could this race with a concurrent transmission and re-activate the DMA
engine across reboot?
Because the network device queues aren't stopped before disabling the TX path
(e.g., via netif_device_detach() or netif_tx_disable()), the networking stack
remains active during shutdown.
If a packet is transmitted concurrently or after the callback runs,
ndo_start_xmit() (lan966x_fdma_xmit()) will execute, acquire tx_lock, and call
lan966x_fdma_tx_start(). Seeing that tx->activated is false, it will
unconditionally set it to true and call lan966x_fdma_tx_activate(tx).
This re-initializes and restarts the hardware DMA channel and explicitly
unmasks the FDMA_INTR_DB_ENA interrupts, which seems to defeat the purpose of
the shutdown callback.
> +
> + napi_synchronize(&lan966x->napi);
> + napi_disable(&lan966x->napi);
Does this napi_disable() call risk a NULL pointer dereference during shutdown?
If the device tree contains no active child nodes under the ethernet-ports
node, or if port initialization fails, lan966x_probe() still returns success.
In this configuration, lan966x->fdma is set to true (since the IRQ was
acquired), but lan966x_fdma_netdev_init() is never invoked. This leaves the
lan966x->napi structure zero-initialized, with napi.dev remaining NULL.
When napi_disable() executes, it locks the associated netdev via
netdev_lock(n->dev), which will crash when n->dev is NULL.
> +
> + lan_wr(0, lan966x, FDMA_INTR_ENA);
> + lan_wr(0, lan966x, FDMA_INTR_DB_ENA);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508-lan966x-pci-fdma-v4-0-14e0c89d8d63@microchip.com?part=8
next prev parent reply other threads:[~2026-05-09 8:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 7:35 [PATCH net-next v4 00/13] net: lan966x: add support for PCIe FDMA Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 01/13] MAINTAINERS: add FDMA library to Sparx5 SoC entry Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 02/13] net: microchip: fdma: rename contiguous dataptr helpers Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 03/13] net: microchip: fdma: add PCIe ATU support Daniel Machon
2026-05-09 8:27 ` sashiko-bot
2026-05-08 7:35 ` [PATCH net-next v4 04/13] net: lan966x: add FDMA LLP register write helper Daniel Machon
2026-05-09 8:27 ` sashiko-bot
2026-05-08 7:35 ` [PATCH net-next v4 05/13] net: lan966x: export FDMA helpers for reuse Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 06/13] net: lan966x: add FDMA ops dispatch for PCIe support Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 07/13] net: lan966x: clear FDMA interrupt stickies after switch reset Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 08/13] net: lan966x: add shutdown callback to stop FDMA on reboot Daniel Machon
2026-05-09 8:27 ` sashiko-bot [this message]
2026-05-08 7:35 ` [PATCH net-next v4 09/13] net: lan966x: add PCIe FDMA support Daniel Machon
2026-05-09 8:27 ` sashiko-bot
2026-05-14 9:05 ` Paolo Abeni
2026-05-14 18:14 ` Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 10/13] net: lan966x: add PCIe FDMA MTU change support Daniel Machon
2026-05-09 8:27 ` sashiko-bot
2026-05-08 7:35 ` [PATCH net-next v4 11/13] net: lan966x: add PCIe FDMA XDP support Daniel Machon
2026-05-09 8:27 ` sashiko-bot
2026-05-08 7:35 ` [PATCH net-next v4 12/13] misc: lan966x-pci: dts: extend cpu reg to cover PCIE DBI space Daniel Machon
2026-05-08 7:35 ` [PATCH net-next v4 13/13] misc: lan966x-pci: dts: add fdma interrupt to overlay Daniel Machon
2026-05-12 2:20 ` [PATCH net-next v4 00/13] net: lan966x: add support for PCIe FDMA Jakub Kicinski
2026-05-12 9:56 ` Daniel Machon
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=20260509082719.94D72C2BCB4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel.machon@microchip.com \
--cc=sashiko@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.