From: Ferruh Yigit Subject: Re: [PATCH] pdump: fix possible mbuf leak Date: Thu, 9 Nov 2017 10:41:15 -0800 Message-ID: <140d63af-200b-a502-c7d4-14d071faf991@intel.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Ilya Matveychikov , dev@dpdk.org Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 349031B26E for ; Thu, 9 Nov 2017 19:41:16 +0100 (CET) In-Reply-To: Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 11/9/2017 5:49 AM, Ilya Matveychikov wrote: > If pdump_pktmbuf_copy_data() fails it's possible to have segment leak > as rte_pktmbuf_free() only handles m_dup chain but not the seg just > allocated and yet not chained. > > Fixes: 278f9454 ("pdump: add new library for packet capture") > Signed-off-by: Ilya V. Matveychikov > --- > lib/librte_pdump/rte_pdump.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c > index 729e79a..1ca709d 100644 > --- a/lib/librte_pdump/rte_pdump.c > +++ b/lib/librte_pdump/rte_pdump.c > @@ -153,6 +153,7 @@ pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp) > do { > nseg++; > if (pdump_pktmbuf_copy_data(seg, m) < 0) { > + if (seg != m_dup) rte_pktmbuf_free(seg); You can prefer rte_pktmbuf_free_seg() Also can you please use two lines? > rte_pktmbuf_free(m_dup); > return NULL; > } > -- > 2.7.4 >