[dpdk-dev] [PATCH] pdump: fix possible mbuf leak

Ferruh Yigit ferruh.yigit at intel.com
Thu Nov 9 19:41:15 CET 2017


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 <matvejchikov at gmail.com>
> ---
>  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
> 



More information about the dev mailing list