[PATCH v3] app/testpmd: fix issue with memory leaks when quit testpmd

Ferruh Yigit ferruh.yigit at xilinx.com
Wed Jun 8 14:06:06 CEST 2022


On 4/4/2022 4:34 PM, Zhang, Yuying wrote:
> Hi Ke,
> 
>> -----Original Message-----
>> From: Zhang, Ke1X <ke1x.zhang at intel.com>
>> Sent: Friday, March 25, 2022 4:36 PM
>> To: Li, Xiaoyun <xiaoyun.li at intel.com>; Singh, Aman Deep
>> <aman.deep.singh at intel.com>; Zhang, Yuying <yuying.zhang at intel.com>;
>> dev at dpdk.org
>> Cc: Zhang, Ke1X <ke1x.zhang at intel.com>
>> Subject: [PATCH v3] app/testpmd: fix issue with memory leaks when quit
>> testpmd
>>
>> A multicast address pool is allocated for a port when using mcast_addr
>> testpmd commands.
>>
>> When closing a port or stopping testpmd, this pool was not freed, resulting in
>> a leak.This issue has been caught using ASan.
>>
>> Free this pool when closing the port.
>>
>> 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.zhang at intel.com>
> 
> Acked-by: Yuying Zhang <yuying.zhang at intel.com>
> 

     Fixes: 8fff667578a7 ("app/testpmd: new command to add/remove 
multicast MAC addresses")
     Cc: stable at dpdk.org

Acked-by: Ferruh Yigit <ferruh.yigit at xilinx.com>

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


<...>

>> pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..1861a02c2f
>> 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -3137,6 +3137,7 @@ close_port(portid_t pid)
>>   		}
>>
>>   		if (is_proc_primary()) {
>> +			mcast_addr_pool_destroy(pi);
>>   			port_flow_flush(pi);
>>   			port_flex_item_flush(pi);
>>   			rte_eth_dev_close(pi);

'rte_eth_dev_close()' may fail, like if the port is not stopped, in that 
case mcast pool will be freed although port is not closed.
This can be prevented by saving existing mcast poll and restore it if 
close failed, but I think it doesn't worth the complexity it brings, so 
OK to continue as it is.


More information about the dev mailing list