From patchwork Tue Dec 5 12:23:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 134880 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7B3843677; Tue, 5 Dec 2023 13:24:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0138742E4B; Tue, 5 Dec 2023 13:24:33 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 77A6A42E2B; Tue, 5 Dec 2023 13:24:31 +0100 (CET) Received: from dggpemm500008.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Sl03W3mrGzFr9C; Tue, 5 Dec 2023 20:20:07 +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_128_GCM_SHA256) id 15.1.2507.35; Tue, 5 Dec 2023 20:24:28 +0800 From: Yunjian Wang To: CC: , , , , Yunjian Wang , Subject: [PATCH v2] net/af_xdp: fix memzone leak in error path Date: Tue, 5 Dec 2023 20:23:51 +0800 Message-ID: X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <64117415a68e8c920efdf905f799b26dcbc3f8fb.1701415014.git.wangyunjian@huawei.com> References: <64117415a68e8c920efdf905f799b26dcbc3f8fb.1701415014.git.wangyunjian@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.242.157] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500008.china.huawei.com (7.185.36.136) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Ciara Loftus Acked-by: Ferruh Yigit --- 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;