diff mbox series

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

Message ID 1554745507-15089-14-git-send-email-g.singh@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series ENETC PMD basic features and bug fixes | expand


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

Commit Message

Gagandeep Singh April 8, 2019, 11:22 a.m. UTC
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: g.singh@nxp.com

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
 drivers/net/enetc/enetc_rxtx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index ed39665..baf5d27 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -49,11 +49,16 @@ 
 		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--) {