Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Suraj Gupta" <suraj.gupta2@amd.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Date: Fri, 24 Jul 2026 14:17:26 +0000	[thread overview]
Message-ID: <20260724141727.3F4CA1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260723123838.125145-3-suraj.gupta2@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] In `axienet_start_xmit_dmaengine()`, if DMA mapping or scatterlist preparation fails, the software TX ring becomes permanently desynchronized from the hardware completions, leading to a double-free of SKBs and memory corruption.
--

--- Patch [2]: [PATCH net-next 2/7] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops ---
commit 1bd6db20edd05b230c296fde4c925b468a67473b
Author: Suraj Gupta <suraj.gupta2@amd.com>
Subject: net: xilinx: axienet: Introduce axienet_config for MAC-specific ops

Introduce an axienet_config structure to abstract MAC-type-specific
operations. This prepares the driver for supporting additional MAC types
beyond the existing 1G Ethernet.

> 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
[ ... ]
> @@ -939,19 +976,21 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev)
>  		goto xmit_error_drop_skb;

[Severity: Critical]
This is a pre-existing issue, but doesn't this error path cause permanent
desynchronization of the TX ring and a double-free?

In axienet_start_xmit_dmaengine(), just before this context:

	lp->tx_ring_head++;
	sg_init_table(skbuf_dma->sgl, sg_len);
	ret = skb_to_sgvec(skb, skbuf_dma->sgl, 0, skb->len);
	if (ret < 0)
		goto xmit_error_drop_skb;

	ret = dma_map_sg(lp->dev, skbuf_dma->sgl, sg_len, DMA_TO_DEVICE);
	if (!ret)
		goto xmit_error_drop_skb;

If skb_to_sgvec() or dma_map_sg() fails, the function jumps to the error path,
drops the SKB, and returns. However, lp->tx_ring_head remains incremented while
no descriptor is actually submitted to the DMA engine.

When a subsequent packet is successfully submitted and completes, the DMA engine
invokes axienet_dma_tx_cb(), which unconditionally fetches the descriptor at
lp->tx_ring_tail++:

	skbuf_dma = axienet_get_tx_desc(lp, lp->tx_ring_tail++);
	...
	dma_unmap_sg(lp->dev, skbuf_dma->sgl, skbuf_dma->sg_len, DMA_TO_DEVICE);
	dev_consume_skb_any(skbuf_dma->skb);

This will fetch the skipped descriptor slot instead of the one that completed.
Since the skipped slot's skb pointer was never updated, it will still point to
the previously freed SKB, leading to a double-free and memory corruption.

Could we fix this by decrementing tx_ring_head on the error path before
returning?

>  	/* Fill up app fields for checksum */
> -	if (skb->ip_summed == CHECKSUM_PARTIAL) {
> -		if (lp->features & XAE_FEATURE_FULL_TX_CSUM) {
> -			/* Tx Full Checksum Offload Enabled */
> -			app_metadata[0] |= 2;
> +	if (lp->axienet_config->dma_tx_csum) {
> +		if (skb->ip_summed == CHECKSUM_PARTIAL) {
> +			if (lp->features & XAE_FEATURE_FULL_TX_CSUM) {
> +				/* Tx Full Checksum Offload Enabled */
> +				app_metadata[0] |= 2;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260723123838.125145-1-suraj.gupta2@amd.com?part=2

  reply	other threads:[~2026-07-24 14:17 UTC|newest]

Thread overview: 14+ 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 [this message]
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-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

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=20260724141727.3F4CA1F00A3A@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