From 84fff3425b896a465a29b92a81aab563c07847cd Mon Sep 17 00:00:00 2001 From: Xiao Wang Date: Fri, 25 Oct 2019 20:33:22 -0400 Subject: [PATCH] net/fm10k: fix mbuf free in vector Rx 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 Signed-off-by: Anna Lukin Reviewed-by: Xiaolong Ye --- drivers/net/fm10k/fm10k_rxtx_vec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k_rxtx_vec.c index 45542bef30..d76dfd16fd 100644 --- a/drivers/net/fm10k/fm10k_rxtx_vec.c +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c @@ -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 */ -- 2.20.1