From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7E2643DA3 for ; Mon, 8 Apr 2024 14:04:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 79DEE40289; Mon, 8 Apr 2024 14:04:47 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id B1AE540041 for ; Mon, 8 Apr 2024 14:04:45 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VCnkg4VbJztS36; Mon, 8 Apr 2024 20:01:47 +0800 (CST) Received: from dggpemm500008.china.huawei.com (unknown [7.185.36.136]) by mail.maildlp.com (Postfix) with ESMTPS id 89F721400CF; Mon, 8 Apr 2024 20:04:28 +0800 (CST) Received: from localhost (10.174.242.157) by dggpemm500008.china.huawei.com (7.185.36.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 8 Apr 2024 20:04:28 +0800 From: Yunjian Wang To: CC: , , , , Yunjian Wang Subject: [PATCH 21.11] net/af_xdp: fix leak on XSK configuration failure Date: Mon, 8 Apr 2024 20:03:09 +0800 Message-ID: <1712577789-21352-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.242.157] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500008.china.huawei.com (7.185.36.136) X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ 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 Reviewed-by: Ciara Loftus Acked-by: Ferruh Yigit --- 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