On 12/5/2023 1:23 AM, wangyunjian wrote: > > >> -----Original Message----- >> From: Ferruh Yigit [mailto:ferruh.yi...@amd.com] >> Sent: Monday, December 4, 2023 10:10 PM >> To: wangyunjian <wangyunj...@huawei.com>; dev@dpdk.org >> Cc: ciara.lof...@intel.com; qi.z.zh...@intel.com; xudingke >> <xudin...@huawei.com>; Lilijun (Jerry) <jerry.lili...@huawei.com>; >> sta...@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: sta...@dpdk.org >>> >>> Signed-off-by: Yunjian Wang <wangyunj...@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.