net/fm10k: fix mbuf free in vector Rx
authorXiao Wang <xiao.w.wang@intel.com>
Sat, 26 Oct 2019 00:33:22 +0000 (20:33 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Nov 2019 22:15:04 +0000 (23:15 +0100)
There's a corner case that all the Rx queue mbufs are allocated but none
of them is used, this patch fixes mbuf free for this case.

Fixes: b6719f8a04bb ("fm10k: release mbuf for vector Rx")
Cc: stable@dpdk.org
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Signed-off-by: Anna Lukin <annal@silicom.co.il>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
drivers/net/fm10k/fm10k_rxtx_vec.c

index 45542be..d76dfd1 100644 (file)
@@ -359,8 +359,15 @@ fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue *rxq)
                return;
 
        /* free all mbufs that are valid in the ring */
-       for (i = rxq->next_dd; i != rxq->rxrearm_start; i = (i + 1) & mask)
-               rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       if (rxq->rxrearm_nb == 0) {
+               for (i = 0; i < rxq->nb_desc; i++)
+                       if (rxq->sw_ring[i] != NULL)
+                               rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       } else {
+               for (i = rxq->next_dd; i != rxq->rxrearm_start;
+                               i = (i + 1) & mask)
+                       rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       }
        rxq->rxrearm_nb = rxq->nb_desc;
 
        /* set all entries to NULL */