Skip to content

Commit 249df69

Browse files
Wei Fangkuba-moo
authored andcommitted
net: enetc: fix the off-by-one issue in enetc_map_tx_tso_buffs()
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]>
1 parent 119049b commit 249df69

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
@@ -859,8 +859,13 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
859859
err = enetc_map_tx_tso_data(tx_ring, skb, tx_swbd, txbd,
860860
tso.data, size,
861861
size == data_len);
862-
if (err)
862+
if (err) {
863+
if (i == 0)
864+
i = tx_ring->bd_count;
865+
i--;
866+
863867
goto err_map_data;
868+
}
864869

865870
data_len -= size;
866871
count++;
@@ -889,13 +894,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
889894
dev_err(tx_ring->dev, "DMA map error");
890895

891896
err_chained_bd:
892-
do {
893-
tx_swbd = &tx_ring->tx_swbd[i];
894-
enetc_free_tx_frame(tx_ring, tx_swbd);
895-
if (i == 0)
896-
i = tx_ring->bd_count;
897-
i--;
898-
} while (count--);
897+
enetc_unwind_tx_frame(tx_ring, count, i);
899898

900899
return 0;
901900
}

0 commit comments

Comments
 (0)