From e091c6915e3ed468d4f5299e409afa4a89436735 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Fri, 12 Apr 2019 12:29:11 +0000 Subject: [PATCH] net/enetc: fix crash at high speed traffic On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue. Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- drivers/net/enetc/enetc_rxtx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c index 0ce7dbee7c..81b0ef3b14 100644 --- a/drivers/net/enetc/enetc_rxtx.c +++ b/drivers/net/enetc/enetc_rxtx.c @@ -49,11 +49,16 @@ enetc_xmit_pkts(void *tx_queue, uint16_t nb_pkts) { struct enetc_swbd *tx_swbd; - int i, start; + int i, start, bds_to_use; struct enetc_tx_bd *txbd; struct enetc_bdr *tx_ring = (struct enetc_bdr *)tx_queue; i = tx_ring->next_to_use; + + bds_to_use = enetc_bd_unused(tx_ring); + if (bds_to_use < nb_pkts) + nb_pkts = bds_to_use; + start = 0; while (nb_pkts--) { enetc_clean_tx_ring(tx_ring); -- 2.20.1