patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 21.11] net/af_xdp: fix leak on XSK configuration failure
@ 2024-04-08 12:03 Yunjian Wang
  2024-04-18 12:30 ` Kevin Traynor
  0 siblings, 1 reply; 2+ messages in thread
From: Yunjian Wang @ 2024-04-08 12:03 UTC (permalink / raw)
  To: stable; +Cc: ktraynor, ciara.loftus, qi.z.zhang, xudingke, Yunjian Wang

[ upstream commit 955acb9594cec548ae57319bfc99d4297d773675 ]

In xdp_umem_configure() allocated some resources for the
xsk umem, we should delete them when xsk configure fails,
otherwise it will lead to resources leak.

Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index dde4024267..d7214c2028 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -916,6 +916,9 @@ remove_xdp_program(struct pmd_internals *internals)
 static void
 xdp_umem_destroy(struct xsk_umem_info *umem)
 {
+	(void)xsk_umem__delete(umem->umem);
+	umem->umem = NULL;
+
 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
 	umem->mb_pool = NULL;
 #else
@@ -948,11 +951,8 @@ eth_dev_close(struct rte_eth_dev *dev)
 			break;
 		xsk_socket__delete(rxq->xsk);
 
-		if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE)
-				== 0) {
-			(void)xsk_umem__delete(rxq->umem->umem);
+		if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
 			xdp_umem_destroy(rxq->umem);
-		}
 
 		/* free pkt_tx_queue */
 		rte_free(rxq->pair);
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 21.11] net/af_xdp: fix leak on XSK configuration failure
  2024-04-08 12:03 [PATCH 21.11] net/af_xdp: fix leak on XSK configuration failure Yunjian Wang
@ 2024-04-18 12:30 ` Kevin Traynor
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Traynor @ 2024-04-18 12:30 UTC (permalink / raw)
  To: Yunjian Wang, stable; +Cc: ciara.loftus, qi.z.zhang, xudingke

On 08/04/2024 13:03, Yunjian Wang wrote:
> [ upstream commit 955acb9594cec548ae57319bfc99d4297d773675 ]
> 
> In xdp_umem_configure() allocated some resources for the
> xsk umem, we should delete them when xsk configure fails,
> otherwise it will lead to resources leak.
> 
> Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Reviewed-by: Ciara Loftus <ciara.loftus@intel.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Thanks Yunjian. I have pushed to 21.11 branch.

Kevin.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-18 12:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08 12:03 [PATCH 21.11] net/af_xdp: fix leak on XSK configuration failure Yunjian Wang
2024-04-18 12:30 ` Kevin Traynor

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).