net/enetc: fix crash at high speed traffic
authorGagandeep Singh <g.singh@nxp.com>
Fri, 12 Apr 2019 12:29:11 +0000 (12:29 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 19 Apr 2019 12:51:54 +0000 (14:51 +0200)
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

index 0ce7dbe..81b0ef3 100644 (file)
@@ -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);