* [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path @ 2023-12-01 8:03 Yunjian Wang 2023-12-04 14:09 ` Ferruh Yigit 2023-12-05 12:23 ` [PATCH v2] " Yunjian Wang 0 siblings, 2 replies; 8+ messages in thread From: Yunjian Wang @ 2023-12-01 8:03 UTC (permalink / raw) To: dev Cc: ciara.loftus, qi.z.zhang, xudingke, jerry.lilijun, Yunjian Wang, stable 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@dpdk.org Signed-off-by: Yunjian Wang <wangyunjian@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); goto err; } umem->mz = mz; -- 2.33.0 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path 2023-12-01 8:03 [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path Yunjian Wang @ 2023-12-04 14:09 ` Ferruh Yigit 2023-12-05 1:23 ` wangyunjian 2023-12-05 12:23 ` [PATCH v2] " Yunjian Wang 1 sibling, 1 reply; 8+ messages in thread From: Ferruh Yigit @ 2023-12-04 14:09 UTC (permalink / raw) To: Yunjian Wang, dev Cc: ciara.loftus, qi.z.zhang, xudingke, jerry.lilijun, stable 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@dpdk.org > > Signed-off-by: Yunjian Wang <wangyunjian@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? > goto err; > } > umem->mz = mz; ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path 2023-12-04 14:09 ` Ferruh Yigit @ 2023-12-05 1:23 ` wangyunjian 2023-12-05 9:41 ` Ferruh Yigit 0 siblings, 1 reply; 8+ messages in thread From: wangyunjian @ 2023-12-05 1:23 UTC (permalink / raw) To: Ferruh Yigit, dev Cc: ciara.loftus, qi.z.zhang, xudingke, Lilijun (Jerry), stable > -----Original Message----- > From: Ferruh Yigit [mailto:ferruh.yigit@amd.com] > Sent: Monday, December 4, 2023 10:10 PM > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org > Cc: ciara.loftus@intel.com; qi.z.zhang@intel.com; xudingke > <xudingke@huawei.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>; > stable@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@dpdk.org > > > > Signed-off-by: Yunjian Wang <wangyunjian@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'. Thanks, Yunjian > > > goto err; > > } > > umem->mz = mz; ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path 2023-12-05 1:23 ` wangyunjian @ 2023-12-05 9:41 ` Ferruh Yigit 2023-12-05 12:31 ` wangyunjian 0 siblings, 1 reply; 8+ messages in thread From: Ferruh Yigit @ 2023-12-05 9:41 UTC (permalink / raw) To: wangyunjian, dev Cc: ciara.loftus, qi.z.zhang, xudingke, Lilijun (Jerry), stable On 12/5/2023 1:23 AM, wangyunjian wrote: > > >> -----Original Message----- >> From: Ferruh Yigit [mailto:ferruh.yigit@amd.com] >> Sent: Monday, December 4, 2023 10:10 PM >> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org >> Cc: ciara.loftus@intel.com; qi.z.zhang@intel.com; xudingke >> <xudingke@huawei.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>; >> stable@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@dpdk.org >>> >>> Signed-off-by: Yunjian Wang <wangyunjian@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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path 2023-12-05 9:41 ` Ferruh Yigit @ 2023-12-05 12:31 ` wangyunjian 0 siblings, 0 replies; 8+ messages in thread From: wangyunjian @ 2023-12-05 12:31 UTC (permalink / raw) To: Ferruh Yigit, dev Cc: ciara.loftus, qi.z.zhang, xudingke, Lilijun (Jerry), stable > -----Original Message----- > From: Ferruh Yigit [mailto:ferruh.yigit@amd.com] > Sent: Tuesday, December 5, 2023 5:42 PM > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org > Cc: ciara.loftus@intel.com; qi.z.zhang@intel.com; xudingke > <xudingke@huawei.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>; > stable@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path > > On 12/5/2023 1:23 AM, wangyunjian wrote: > > > > > >> -----Original Message----- > >> From: Ferruh Yigit [mailto:ferruh.yigit@amd.com] > >> Sent: Monday, December 4, 2023 10:10 PM > >> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org > >> Cc: ciara.loftus@intel.com; qi.z.zhang@intel.com; xudingke > >> <xudingke@huawei.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>; > >> stable@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@dpdk.org > >>> > >>> Signed-off-by: Yunjian Wang <wangyunjian@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. OK, I update the patch in v2. Thanks. https://patchwork.dpdk.org/project/dpdk/patch/ab06b0b804b4b27ea8444381ea14a98a3c3231bb.1701778603.git.wangyunjian@huawei.com/ > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] net/af_xdp: fix memzone leak in error path 2023-12-01 8:03 [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path Yunjian Wang 2023-12-04 14:09 ` Ferruh Yigit @ 2023-12-05 12:23 ` Yunjian Wang 2023-12-05 13:16 ` Loftus, Ciara 1 sibling, 1 reply; 8+ messages in thread From: Yunjian Wang @ 2023-12-05 12:23 UTC (permalink / raw) To: dev Cc: ferruh.yigit, ciara.loftus, qi.z.zhang, xudingke, Yunjian Wang, stable 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. To fix it move 'umem->mz = mz;' assignment after 'mz == NULL' check. Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang <wangyunjian@huawei.com> --- v2: update code suggested by Ferruh Yigit --- drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 353c8688ec..9f0f751d4a 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -1235,6 +1235,7 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals, goto err; } + umem->mz = mz; ret = xsk_umem__create(&umem->umem, mz->addr, ETH_AF_XDP_NUM_BUFFERS * ETH_AF_XDP_FRAME_SIZE, &rxq->fq, &rxq->cq, @@ -1244,7 +1245,6 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals, AF_XDP_LOG(ERR, "Failed to create umem\n"); goto err; } - umem->mz = mz; return umem; -- 2.33.0 ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH v2] net/af_xdp: fix memzone leak in error path 2023-12-05 12:23 ` [PATCH v2] " Yunjian Wang @ 2023-12-05 13:16 ` Loftus, Ciara 2023-12-06 12:29 ` Ferruh Yigit 0 siblings, 1 reply; 8+ messages in thread From: Loftus, Ciara @ 2023-12-05 13:16 UTC (permalink / raw) To: Yunjian Wang, dev; +Cc: ferruh.yigit, Zhang, Qi Z, xudingke, stable > > 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. To fix it move 'umem->mz = mz;' assignment after > 'mz == NULL' check. > > Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD") > Cc: stable@dpdk.org > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com> > --- > v2: update code suggested by Ferruh Yigit > --- > drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c > b/drivers/net/af_xdp/rte_eth_af_xdp.c > index 353c8688ec..9f0f751d4a 100644 > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c > @@ -1235,6 +1235,7 @@ xsk_umem_info *xdp_umem_configure(struct > pmd_internals *internals, > goto err; > } > > + umem->mz = mz; > ret = xsk_umem__create(&umem->umem, mz->addr, > ETH_AF_XDP_NUM_BUFFERS * > ETH_AF_XDP_FRAME_SIZE, > &rxq->fq, &rxq->cq, > @@ -1244,7 +1245,6 @@ xsk_umem_info *xdp_umem_configure(struct > pmd_internals *internals, > AF_XDP_LOG(ERR, "Failed to create umem\n"); > goto err; > } > - umem->mz = mz; > > return umem; > > -- > 2.33.0 Thank you for the patch. Acked-by: Ciara Loftus <ciara.loftus@intel.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] net/af_xdp: fix memzone leak in error path 2023-12-05 13:16 ` Loftus, Ciara @ 2023-12-06 12:29 ` Ferruh Yigit 0 siblings, 0 replies; 8+ messages in thread From: Ferruh Yigit @ 2023-12-06 12:29 UTC (permalink / raw) To: Loftus, Ciara, Yunjian Wang, dev; +Cc: Zhang, Qi Z, xudingke, stable On 12/5/2023 1:16 PM, Loftus, Ciara 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. To fix it move 'umem->mz = mz;' assignment after >> 'mz == NULL' check. >> >> Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD") >> Cc: stable@dpdk.org >> >> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com> >> --- >> v2: update code suggested by Ferruh Yigit >> --- >> drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c >> b/drivers/net/af_xdp/rte_eth_af_xdp.c >> index 353c8688ec..9f0f751d4a 100644 >> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c >> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c >> @@ -1235,6 +1235,7 @@ xsk_umem_info *xdp_umem_configure(struct >> pmd_internals *internals, >> goto err; >> } >> >> + umem->mz = mz; > Moved one line up, to group with mz alloc/check block, while merging. >> ret = xsk_umem__create(&umem->umem, mz->addr, >> ETH_AF_XDP_NUM_BUFFERS * >> ETH_AF_XDP_FRAME_SIZE, >> &rxq->fq, &rxq->cq, >> @@ -1244,7 +1245,6 @@ xsk_umem_info *xdp_umem_configure(struct >> pmd_internals *internals, >> AF_XDP_LOG(ERR, "Failed to create umem\n"); >> goto err; >> } >> - umem->mz = mz; >> >> return umem; >> >> -- >> 2.33.0 > > Thank you for the patch. > > Acked-by: Ciara Loftus <ciara.loftus@intel.com> > Acked-by: Ferruh Yigit <ferruh.yigit@amd.com> Applied to dpdk-next-net/main, thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-06 12:29 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-12-01 8:03 [dpdk-dev] [PATCH] net/af_xdp: fix memzone leak in error path Yunjian Wang 2023-12-04 14:09 ` Ferruh Yigit 2023-12-05 1:23 ` wangyunjian 2023-12-05 9:41 ` Ferruh Yigit 2023-12-05 12:31 ` wangyunjian 2023-12-05 12:23 ` [PATCH v2] " Yunjian Wang 2023-12-05 13:16 ` Loftus, Ciara 2023-12-06 12:29 ` Ferruh Yigit
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).