Skip to content

Commit da29199

Browse files
Wei Fangkuba-moo
authored andcommitted
net: enetc: keep track of correct Tx BD count in enetc_map_tx_tso_buffs()
When creating a TSO header, if the skb is VLAN tagged, the extended BD will be used and the 'count' should be increased by 2 instead of 1. Otherwise, when an error occurs, less tx_swbd will be freed than the actual number. 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 39ab773 commit da29199

File tree

1 file changed

+10
-6
lines changed
  • drivers/net/ethernet/freescale/enetc

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,15 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb)
395395
return 0;
396396
}
397397

398-
static void enetc_map_tx_tso_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb,
399-
struct enetc_tx_swbd *tx_swbd,
400-
union enetc_tx_bd *txbd, int *i, int hdr_len,
401-
int data_len)
398+
static int enetc_map_tx_tso_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb,
399+
struct enetc_tx_swbd *tx_swbd,
400+
union enetc_tx_bd *txbd, int *i, int hdr_len,
401+
int data_len)
402402
{
403403
union enetc_tx_bd txbd_tmp;
404404
u8 flags = 0, e_flags = 0;
405405
dma_addr_t addr;
406+
int count = 1;
406407

407408
enetc_clear_tx_bd(&txbd_tmp);
408409
addr = tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE;
@@ -445,7 +446,10 @@ static void enetc_map_tx_tso_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb,
445446
/* Write the BD */
446447
txbd_tmp.ext.e_flags = e_flags;
447448
*txbd = txbd_tmp;
449+
count++;
448450
}
451+
452+
return count;
449453
}
450454

451455
static int enetc_map_tx_tso_data(struct enetc_bdr *tx_ring, struct sk_buff *skb,
@@ -802,9 +806,9 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb
802806

803807
/* compute the csum over the L4 header */
804808
csum = enetc_tso_hdr_csum(&tso, skb, hdr, hdr_len, &pos);
805-
enetc_map_tx_tso_hdr(tx_ring, skb, tx_swbd, txbd, &i, hdr_len, data_len);
809+
count += enetc_map_tx_tso_hdr(tx_ring, skb, tx_swbd, txbd,
810+
&i, hdr_len, data_len);
806811
bd_data_num = 0;
807-
count++;
808812

809813
while (data_len > 0) {
810814
int size;

0 commit comments

Comments
 (0)