pdump: fix possible mbuf leak
PATCH 1/1 pdump: fix possible mbuf leak
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.
--- lib/librte_pdump/rte_pdump.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_pdump/rte_pdump.c +1 -0
@@ -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); rte_pktmbuf_free(m_dup); return NULL; }
--
2.7.4
Quoted 15 lines · Ilya Matveychikov
If
pdump_pktmbuf_copy_data()fails it's possible to have segment leak asrte_pktmbuf_free()only handlesm_dupchain 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 <[email protected]>--- lib/librte_pdump/rte_pdump.c | 1 + 1 file changed, 1 insertion(+)lib/librte_pdump/rte_pdump.c +0
-0
lib/librte_pdump/rte_pdump.c pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp) · line 156
Quoted 4 lines
lib/librte_pdump/rte_pdump.c +1
-0@@ -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?
Quoted 6 lines
lib/librte_pdump/rte_pdump.c +0
-1rte_pktmbuf_free (m_dup);return NULL ; } --2.7.4
PATCH 1/4 pdump: fix possible mbuf leak
In reply to Ilya MatveychikovIf 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.
--- lib/librte_pdump/rte_pdump.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_pdump/rte_pdump.c +1 -0
@@ -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); rte_pktmbuf_free(m_dup); return NULL; }
Signature · 1 line
2.7.4
PATCH 1/1 pdump: fix possible mbuf leak
In reply to Ilya MatveychikovIf 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.
--- lib/librte_pdump/rte_pdump.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_pdump/rte_pdump.c +2 -0
@@ -153,6 +153,8 @@ 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(seg); rte_pktmbuf_free(m_dup); return NULL; }
Signature · 1 line
2.14.2
Thomas Monjalon
Applied10/11/2017 14:55, Ilya V. Matveychikov:
Quoted 8 lines
If
pdump_pktmbuf_copy_data()fails it's possible to have segment leak asrte_pktmbuf_free()only handlesm_dupchain but not the seg just allocated and yet not chained.Fixes 278f945402c5 ("pdump: add new library for packet capture")Signed-off-by Ilya V. Matveychikov <[email protected]>
Applied, thanks