FAILED: patch "[PATCH] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()" failed to apply to 5.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y
git checkout FETCH_HEAD
git cherry-pick -x 39ab773e4c120f7f98d759415ccc2aca706bbc10
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025030409-primp-ripcord-cc40@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 39ab773e4c120f7f98d759415ccc2aca706bbc10 Mon Sep 17 00:00:00 2001
From: Wei Fang <[email protected]>
Date: Mon, 24 Feb 2025 19:12:44 +0800
Subject: [PATCH] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()
When a DMA mapping error occurs while processing skb frags, it will free one more tx_swbd than expected, so fix this off-by-one issue.
drivers/net/ethernet/freescale/enetc/enetc.c +19 -7
@@ -167,6 +167,24 @@ static bool enetc_skb_is_tcp(struct sk_buff *skb)return skb->csum_offset == offsetof(struct tcphdr , check); } +/** +* enetc_unwind_tx_frame() - Unwind the DMA mappings of a multi-buffer Tx frame +* @tx_ring: Pointer to the Tx ring on which the buffer descriptors are located +* @count: Number of Tx buffer descriptors which need to be unmapped +* @i: Index of the last successfully mapped Tx buffer descriptor +*/ +static void enetc_unwind_tx_frame (struct enetc_bdr *tx_ring,int count,int i) +{ +while (count--) { +struct enetc_tx_swbd *tx_swbd = &tx_ring->tx_swbd[i]; + +enetc_free_tx_frame (tx_ring, tx_swbd); +if (i ==0 ) + i = tx_ring->bd_count; + i--; + } +} +static int enetc_map_tx_buffs (struct enetc_bdr *tx_ring,struct sk_buff *skb) {bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false;
@@ -372,13 +390,7 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) dma_err:dev_err (tx_ring->dev,"DMA map error" ); -do { - tx_swbd = &tx_ring->tx_swbd[i]; -enetc_free_tx_frame (tx_ring, tx_swbd); -if (i ==0 ) - i = tx_ring->bd_count; - i--; - }while (count--); +enetc_unwind_tx_frame (tx_ring, count, i);return 0 ; }