[dpdk-dev] [PATCH] pcap: fix memory leak in jumbo frames

Dror Birkman dror.birkman at lightcyber.com
Tue Sep 20 12:39:23 CEST 2016


If rte_pktmbuf_alloc() fails on any segment that is not the initial
segment, previously allocated mbufs are not freed.

Signed-off-by: Dror Birkman <dror.birkman at lightcyber.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index b7a3b03..db19a66 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -229,8 +229,10 @@ eth_pcap_rx(void *queue,
 			if (unlikely(eth_pcap_rx_jumbo(pcap_q->mb_pool,
 						       mbuf,
 						       packet,
-						       header.caplen) == -1))
+						       header.caplen) == -1)) {
+				rte_pktmbuf_free(mbuf);
 				break;
+			}
 		}
 
 		mbuf->pkt_len = (uint16_t)header.caplen;
-- 
2.3.0



More information about the dev mailing list