[dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path

Ferruh Yigit ferruh.yigit at amd.com
Tue Dec 5 10:41:41 CET 2023


On 12/5/2023 1:23 AM, wangyunjian wrote:
> 
> 
>> -----Original Message-----
>> From: Ferruh Yigit [mailto:ferruh.yigit at amd.com]
>> Sent: Monday, December 4, 2023 10:10 PM
>> To: wangyunjian <wangyunjian at huawei.com>; dev at dpdk.org
>> Cc: ciara.loftus at intel.com; qi.z.zhang at intel.com; xudingke
>> <xudingke at huawei.com>; Lilijun (Jerry) <jerry.lilijun at huawei.com>;
>> stable at dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path
>>
>> On 12/1/2023 8:03 AM, Yunjian Wang wrote:
>>> In xdp_umem_configure() allocated memzone for the 'umem', we should
>>> free it when xsk_umem__create() call fails, otherwise it will lead to
>>> memory zone leak.
>>>
>>> Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
>>> Cc: stable at dpdk.org
>>>
>>> Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
>>> ---
>>>  drivers/net/af_xdp/rte_eth_af_xdp.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
>>> b/drivers/net/af_xdp/rte_eth_af_xdp.c
>>> index 2a20a6960c..2a1fdafb3c 100644
>>> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
>>> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
>>> @@ -1229,6 +1229,7 @@ xsk_umem_info *xdp_umem_configure(struct
>>> pmd_internals *internals,
>>>
>>>  	if (ret) {
>>>  		AF_XDP_LOG(ERR, "Failed to create umem\n");
>>> +		rte_memzone_free(mz);
>>>
>>
>> Doesn't 'xdp_umem_destroy()', in the label 'err', already free it?
> 
> In this case, 'mz' is not assigned to 'umem->mz'. Therefore,
> the'xdp_umem_destroy()' does not free 'mz'.
> 
> 

True.
What do you think to move 'umem->mz = mz;' assignment after 'mz == NULL'
check? So related code can be grouped together.






More information about the stable mailing list