when dpdk is compiled in ASan, there is a memory leaks after quit testpmd if set mcast_addr, this patch fix this issue.
Error info as following: ERROR: LeakSanitizer: detected memory leaksDirect leak of 192 byte(s) 0 0x7f6a2e0aeffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe) 1 0x565361eb340f in mcast_addr_pool_extend ../app/test-pmd/config.c:5162 2 0x565361eb3556 in mcast_addr_pool_append ../app/test-pmd/config.c:5180 3 0x565361eb3aae in mcast_addr_add ../app/test-pmd/config.c:5243 Signed-off-by: Ke Zhang <ke1x.zh...@intel.com> --- app/test-pmd/testpmd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..fa7f80fdf7 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2742,6 +2742,8 @@ start_port(portid_t pid) continue; } + port->mc_addr_pool = NULL; + if (port->need_reconfig > 0) { struct rte_eth_conf dev_conf; int k; @@ -3065,6 +3067,16 @@ stop_port(portid_t pid) if (eth_dev_stop_mp(pi) != 0) RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", pi); + /* + * free the pool of multicast addresses. If it is NULL, + * it means there is no mc addr.Make sure the mc_addr_pool + * is NULL at port init. + */ + if (port->mc_addr_pool != NULL) { + free(port->mc_addr_pool); + port->mc_addr_pool = NULL; + } + port->mc_addr_nb = 0; if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; -- 2.25.1