app/testpmd: fix mbuf leak in the case of multi-segment Tx

Message ID 1557311257-10719-1-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix mbuf leak in the case of multi-segment Tx |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Rybchenko May 8, 2019, 10:27 a.m. UTC
  The last mbuf allocated in bulk is never used and never freed.

Fixes: 01b645dcff7f ("app/testpmd: move txonly prepare in separate function")
Fixes: 561ddcf8d099 ("app/testpmd: allocate txonly segments per bulk")

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 app/test-pmd/txonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit May 8, 2019, 6:32 p.m. UTC | #1
On 5/8/2019 11:27 AM, Andrew Rybchenko wrote:
> The last mbuf allocated in bulk is never used and never freed.
> 
> Fixes: 01b645dcff7f ("app/testpmd: move txonly prepare in separate function")
> Fixes: 561ddcf8d099 ("app/testpmd: allocate txonly segments per bulk")
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Good catch!

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index fa8e0c0..fdfca14 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -167,7 +167,7 @@ 
 		nb_segs = tx_pkt_nb_segs;
 
 	if (nb_segs > 1) {
-		if (rte_mempool_get_bulk(mbp, (void **)pkt_segs, nb_segs))
+		if (rte_mempool_get_bulk(mbp, (void **)pkt_segs, nb_segs - 1))
 			return false;
 	}