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 BF908A0350; Sat, 8 Jan 2022 08:52:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3EE6840689; Sat, 8 Jan 2022 08:52:10 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 420B440042; Sat, 8 Jan 2022 08:52:07 +0100 (CET) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JWBzQ5WJ4zZdrd; Sat, 8 Jan 2022 15:48:34 +0800 (CST) Received: from dggpemm500008.china.huawei.com (7.185.36.136) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 8 Jan 2022 15:52:05 +0800 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.2308.20; Sat, 8 Jan 2022 15:52:05 +0800 From: Yunjian Wang To: CC: , , , , , Yunjian Wang , Subject: [dpdk-dev] [PATCH] ethdev: fix rxq_state leak in error path Date: Sat, 8 Jan 2022 15:51:57 +0800 Message-ID: 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: dggems705-chm.china.huawei.com (10.3.19.182) 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 eth_dev_handle_port_info() allocated memory for rxq_state, we should free it when error happens, otherwise it will lead to memory leak. Fixes: 58b43c1ddfd1 ("ethdev: add telemetry endpoint for device info") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- lib/ethdev/rte_ethdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index a1d475a292..29e21ad580 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6320,8 +6320,10 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, return -ENOMEM; txq_state = rte_tel_data_alloc(); - if (!txq_state) + if (!txq_state) { + rte_tel_data_free(rxq_state); return -ENOMEM; + } rte_tel_data_start_dict(d); rte_tel_data_add_dict_string(d, "name", eth_dev->data->name); -- 2.27.0