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

Message ID 1474373336-85875-1-git-send-email-dror.birkman@lightcyber.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Dror Birkman Sept. 20, 2016, 12:08 p.m. UTC
  If rte_pktmbuf_alloc() fails on any segment that is not the initial
segment, previously allocated mbufs are not freed.

Fixes: 6db141c91e1f ("pcap: support jumbo frames")

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

Comments

Ferruh Yigit Sept. 20, 2016, 1:12 p.m. UTC | #1
Hi Dror,

On 9/20/2016 1:08 PM, Dror Birkman wrote:
> If rte_pktmbuf_alloc() fails on any segment that is not the initial
> segment, previously allocated mbufs are not freed.
> 
> Fixes: 6db141c91e1f ("pcap: support jumbo frames")
> 
> Cc: <stable@dpdk.org>
> Signed-off-by: Dror Birkman <dror.birkman@lightcyber.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Bruce Richardson Sept. 21, 2016, 10:57 a.m. UTC | #2
On Tue, Sep 20, 2016 at 02:12:38PM +0100, Ferruh Yigit wrote:
> Hi Dror,
> 
> On 9/20/2016 1:08 PM, Dror Birkman wrote:
> > If rte_pktmbuf_alloc() fails on any segment that is not the initial
> > segment, previously allocated mbufs are not freed.
> > 
> > Fixes: 6db141c91e1f ("pcap: support jumbo frames")
> > 
> > Cc: <stable@dpdk.org>
> > Signed-off-by: Dror Birkman <dror.birkman@lightcyber.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 
Applied to dpdk-next-net/rel_16_11

/Bruce
  

Patch

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;