[v4,13/13] net/enetc: fix crash at high speed traffic

Message ID 20190412122840.1908-14-g.singh@nxp.com
State Accepted
Delegated to: Ferruh Yigit
Headers show
Series
  • ENETC PMD basic features and bug fixes
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Gagandeep Singh April 12, 2019, 12:29 p.m.
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 <g.singh@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 0ce7dbee7..81b0ef3b1 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);