Skip to content

Commit 143ceb0

Browse files
Sunil Gouthamdavem330
authored andcommitted
net: thunderx: Fix memory leak while tearing down interface
Fixed 'tso_hdrs' memory not being freed properly. Also fixed SQ skbuff maintenance issues. Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Aleksey Makarov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4b561c1 commit 143ceb0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev,
425425
if (skb) {
426426
prefetch(skb);
427427
dev_consume_skb_any(skb);
428+
sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL;
428429
}
429430
}
430431

drivers/net/ethernet/cavium/thunder/nicvf_queues.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ static void nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq)
382382
return;
383383

384384
if (sq->tso_hdrs)
385-
dma_free_coherent(&nic->pdev->dev, sq->dmem.q_len,
385+
dma_free_coherent(&nic->pdev->dev,
386+
sq->dmem.q_len * TSO_HEADER_SIZE,
386387
sq->tso_hdrs, sq->tso_hdrs_phys);
387388

388389
kfree(sq->skbuff);
@@ -863,10 +864,11 @@ void nicvf_sq_free_used_descs(struct net_device *netdev, struct snd_queue *sq,
863864
continue;
864865
}
865866
skb = (struct sk_buff *)sq->skbuff[sq->head];
867+
if (skb)
868+
dev_kfree_skb_any(skb);
866869
atomic64_add(1, (atomic64_t *)&netdev->stats.tx_packets);
867870
atomic64_add(hdr->tot_len,
868871
(atomic64_t *)&netdev->stats.tx_bytes);
869-
dev_kfree_skb_any(skb);
870872
nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
871873
}
872874
}
@@ -1048,7 +1050,7 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq,
10481050
}
10491051
nicvf_sq_add_hdr_subdesc(sq, hdr_qentry,
10501052
seg_subdescs - 1, skb, seg_len);
1051-
sq->skbuff[hdr_qentry] = 0;
1053+
sq->skbuff[hdr_qentry] = (u64)NULL;
10521054
qentry = nicvf_get_nxt_sqentry(sq, qentry);
10531055

10541056
desc_cnt += seg_subdescs;

0 commit comments

Comments
 (0)