Skip to content

Commit 39f843e

Browse files
Wei Fanggregkh
authored andcommitted
net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs()
commit 249df695c3ffe8c8d36d46c2580ce72410976f96 upstream. There is an off-by-one issue for the err_chained_bd path, it will free one more tx_swbd than expected. But there is no such issue for the err_map_data path. To fix this off-by-one issue and make the two error handling consistent, the increment of 'i' and 'count' remain in sync and enetc_unwind_tx_frame() is called for error handling. Fixes: fb8629e ("net: enetc: add support for software TSO") Cc: [email protected] Suggested-by: Vladimir Oltean <[email protected]> Signed-off-by: Wei Fang <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Reviewed-by: Claudiu Manoil <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 45b8d6c commit 39f843e

File tree

1 file changed

+7
-8
lines changed
  • drivers/net/ethernet/freescale/enetc

1 file changed

+7
-8
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,13 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
568568
err = enetc_map_tx_tso_data(tx_ring, skb, tx_swbd, txbd,
569569
tso.data, size,
570570
size == data_len);
571-
if (err)
571+
if (err) {
572+
if (i == 0)
573+
i = tx_ring->bd_count;
574+
i--;
575+
572576
goto err_map_data;
577+
}
573578

574579
data_len -= size;
575580
count++;
@@ -598,13 +603,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
598603
dev_err(tx_ring->dev, "DMA map error");
599604

600605
err_chained_bd:
601-
do {
602-
tx_swbd = &tx_ring->tx_swbd[i];
603-
enetc_free_tx_frame(tx_ring, tx_swbd);
604-
if (i == 0)
605-
i = tx_ring->bd_count;
606-
i--;
607-
} while (count--);
606+
enetc_unwind_tx_frame(tx_ring, count, i);
608607

609608
return 0;
610609
}

0 commit comments

Comments
 (0)