From: sashiko-bot@kernel.org
To: "Suraj Gupta" <suraj.gupta2@amd.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v2 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Date: Fri, 07 Aug 2026 18:13:12 +0000 [thread overview]
Message-ID: <20260807181313.BBCC91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806181153.1213996-3-suraj.gupta2@amd.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Medium] Unconditional scheduling of the periodic stats refresh work, even if the MAC type does not implement stats_update.
Pre-existing issues:
- [High] axienet_open() unconditionally overwrites the return value of axienet_device_reset(), ignoring initialization failures.
- [High] axienet_stop() leaks SKB buffers and DMA mappings when using the dmaengine path.
- [High] The DMA error handler tears down the TX and RX rings without stopping the network stack's TX queue, leading to concurrent memory corruption.
--
--- Patch [2]: [PATCH net-next v2 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops ---
commit c91bc423b631f26b67969fe9f4dd575e433a235f
Author: Suraj Gupta <suraj.gupta2@amd.com>
net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
This commit introduces an axienet_config structure to abstract
MAC-type-specific operations and capability flags. It populates this
configuration from the OF match table and updates the driver to use these
callbacks instead of open-coding 1G behavior. This prepares the driver for
supporting additional MAC types in the future.
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index fcf517069d161..b3deba1d96f7e 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
[ ... ]
> @@ -576,14 +573,25 @@ static void axienet_stats_update(struct axienet_local *lp, bool reset)
> write_seqcount_end(&lp->hw_stats_seqcount);
> }
>
> +/**
> + * axienet_1g_stats_update - Refresh 1G MAC hardware statistics
> + * @lp: Pointer to the axienet_local structure
> + */
> +static void axienet_1g_stats_update(struct axienet_local *lp)
> +{
> + axienet_stats_update(lp, false);
> +}
> +
> static void axienet_refresh_stats(struct work_struct *work)
> {
> struct axienet_local *lp = container_of(work, struct axienet_local,
> stats_work.work);
>
> - mutex_lock(&lp->stats_lock);
> - axienet_stats_update(lp, false);
> - mutex_unlock(&lp->stats_lock);
> + if (lp->axienet_config->stats_update) {
> + mutex_lock(&lp->stats_lock);
> + lp->axienet_config->stats_update(lp);
> + mutex_unlock(&lp->stats_lock);
> + }
>
> /* Just less than 2^32 bytes at 2.5 GBit/s */
> schedule_delayed_work(&lp->stats_work, 13 * HZ);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: Medium]
Is it necessary to reschedule the periodic stats refresh work if the
configured MAC type does not implement stats_update?
Since schedule_delayed_work() is called unconditionally, it seems this might
wake up a CPU every 13 seconds while the interface is up, performing no
actual work if lp->axienet_config->stats_update is NULL.
[ ... ]
> @@ -709,19 +743,23 @@ static int axienet_device_reset(struct net_device *ndev)
> {
> - u32 axienet_status;
> struct axienet_local *lp = netdev_priv(ndev);
> int ret;
>
> + if (lp->axienet_config->gt_reset)
> + lp->axienet_config->gt_reset(lp);
> +
> lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE;
[Severity: High]
This is a pre-existing issue, but since axienet_device_reset() can fail and
propagate error codes, is its return value properly checked in all callers?
Looking at axienet_open(), the return value of axienet_device_reset() is
stored in 'ret' but is immediately overwritten:
axienet_open() {
...
ret = axienet_device_reset(ndev);
axienet_unlock_mii(lp);
ret = phylink_of_phy_connect(lp->phylink, lp->dev->of_node, 0);
...
}
Could this lead to the network interface being brought up in an incomplete
state if hardware initialization or descriptor allocation fails?
[ ... ]
> @@ -1742,8 +1781,8 @@ static int axienet_stop(struct net_device *ndev)
> phylink_stop(lp->phylink);
> phylink_disconnect_phy(lp->phylink);
>
> - axienet_setoptions(ndev, lp->options &
> - ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
> + lp->axienet_config->setoptions(ndev, lp->options &
> + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
>
> if (!lp->use_dmaengine) {
> axienet_dma_stop(lp);
[Severity: High]
This isn't a bug introduced by this patch, but does the dmaengine teardown
path in axienet_stop() leak SKB buffers?
In the dmaengine branch of axienet_stop():
axienet_stop() {
...
} else {
...
for (i = 0; i < TX_BD_NUM_MAX; i++)
kfree(lp->tx_skb_ring[i]);
kfree(lp->tx_skb_ring);
...
}
It appears the skbuf_dma wrapper structures are freed, but there is no call
to unmap the DMA addresses or free the enclosed skb pointers themselves.
Could this lead to memory leaks and orphaned DMA mappings when the interface
is brought down?
[ ... ]
> @@ -2698,7 +2760,6 @@ static const struct phylink_mac_ops axienet_phylink_ops = {
> static void axienet_dma_err_handler(struct work_struct *work)
> {
> u32 i;
> - u32 axienet_status;
> struct axidma_bd *cur_p;
> struct axienet_local *lp = container_of(work, struct axienet_local,
> dma_err_task);
> @@ -2711,8 +2772,8 @@ static void axienet_dma_err_handler(struct work_struct *work)
> napi_disable(&lp->napi_tx);
> napi_disable(&lp->napi_rx);
>
> - axienet_setoptions(ndev, lp->options &
> - ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
> + lp->axienet_config->setoptions(ndev, lp->options &
> + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
>
> axienet_dma_stop(lp);
[Severity: High]
This is a pre-existing issue, but does the DMA error handler safely stop the
TX queue before manipulating the rings?
Looking at axienet_dma_err_handler(), it loops over the TX ring and locklessly
frees the SKBs:
axienet_dma_err_handler() {
...
for (i = 0; i < lp->tx_bd_num; i++) {
...
if (cur_p->skb)
dev_kfree_skb_irq(cur_p->skb);
...
}
Since netif_tx_disable() is not called, could axienet_start_xmit() be
concurrently invoked by the networking stack and write new SKBs to this same
ring, leading to data races, double-frees, or memory corruption?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806181153.1213996-1-suraj.gupta2@amd.com?part=2
next prev parent reply other threads:[~2026-08-07 18:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 12:38 [PATCH net-next 0/7] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-07-23 12:38 ` [PATCH net-next 1/7] clk: Add devm_clk_bulk_get_enable() Suraj Gupta
2026-07-23 15:04 ` Brian Masney
2026-07-24 14:17 ` sashiko-bot
2026-07-23 12:38 ` [PATCH net-next 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops Suraj Gupta
2026-07-24 14:17 ` sashiko-bot
2026-07-23 12:38 ` [PATCH net-next 3/7] dt-bindings: net: xlnx,axi-ethernet: Add 10G/25G (XXV) ethernet Suraj Gupta
2026-07-24 13:16 ` Rob Herring (Arm)
2026-07-28 13:56 ` Rob Herring
2026-07-23 12:38 ` [PATCH net-next 4/7] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-07-24 14:17 ` sashiko-bot
2026-07-23 12:38 ` [PATCH net-next 5/7] net: xilinx: axienet: Make axienet_rmon_ranges non-static for reuse Suraj Gupta
2026-07-23 12:38 ` [PATCH net-next 6/7] net: xilinx: axienet: Dispatch statistics through axienet_config ops Suraj Gupta
2026-07-24 14:17 ` sashiko-bot
2026-07-23 12:38 ` [PATCH net-next 7/7] net: xilinx: axienet: Add statistics support for XXV ethernet Suraj Gupta
2026-08-06 18:11 ` [PATCH net-next v2 0/7] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-08-06 18:11 ` [PATCH net-next v2 1/7] clk: Add devm_clk_bulk_get_enable() Suraj Gupta
2026-08-07 18:13 ` sashiko-bot
2026-08-06 18:11 ` [PATCH net-next v2 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops Suraj Gupta
2026-08-07 18:13 ` sashiko-bot [this message]
2026-08-06 18:11 ` [PATCH net-next v2 3/7] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet Suraj Gupta
2026-08-06 18:11 ` [PATCH net-next v2 4/7] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-08-07 18:13 ` sashiko-bot
2026-08-06 18:11 ` [PATCH net-next v2 5/7] net: xilinx: axienet: Make axienet_rmon_ranges non-static for reuse Suraj Gupta
2026-08-06 18:11 ` [PATCH net-next v2 6/7] net: xilinx: axienet: Dispatch statistics through axienet_config ops Suraj Gupta
2026-08-07 18:13 ` sashiko-bot
2026-08-06 18:11 ` [PATCH net-next v2 7/7] net: xilinx: axienet: Add statistics support for XXV ethernet Suraj Gupta
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=20260807181313.BBCC91F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=suraj.gupta2@amd.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