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 3FBE241EB5; Thu, 16 Mar 2023 22:30:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF09842FB4; Thu, 16 Mar 2023 22:29:46 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 92AFE40DF6 for ; Thu, 16 Mar 2023 22:29:39 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32GFtBbe005959 for ; Thu, 16 Mar 2023 14:29:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=wtXoXKm0PtwCPi3upxBKk5UZ5Dqyol3NXycmb/V7RQo=; b=bVwnfORvbHG9SCSmlbXdSzpM4FCJQWjUQang+mRzRTAbEZX3sD+bEsM67LNEndooLg+Z ZSuNw7GyseNbhdfqnPkUdiXgRpcF+QT54Y0zmBz8bFq95JgkVvDOkzFXtEBTR6SOkdL0 0TS2Gc90f/TP9rE8dtt2gyKtxfuR51bQVFBLPDSyz5caTQ/rYCSbxvfVv1sAlEM+SnL1 YIwgLdzV9b/q0XHhXmx8agX7pTfKbcIob4pcoI2XBbShxAwmo0WywaCD+Dj6LeFdBWbO pu01t/omW0XMKR9YvaCnnczwk2l2cwaBRm2Mb5Rs2vyVJBQHf36pz+TTvyfwQ3Y5Vx8Y BQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pbxq2ucrk-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 16 Mar 2023 14:29:38 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 14:29:36 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 16 Mar 2023 14:29:35 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id ED8CB3F708F; Thu, 16 Mar 2023 14:29:35 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi , Prince Takkar CC: , , , Subject: [PATCH v3 5/8] ml/cnxk: fix potential memory leak in xstats Date: Thu, 16 Mar 2023 14:29:01 -0700 Message-ID: <20230316212904.9318-6-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230316212904.9318-1-syalavarthi@marvell.com> References: <20230315135427.11489-1-syalavarthi@marvell.com> <20230316212904.9318-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: q5D5HfHgXNaqHz9EH52a6So2aqEnewrr X-Proofpoint-ORIG-GUID: q5D5HfHgXNaqHz9EH52a6So2aqEnewrr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-16_14,2023-03-16_02,2023-02-09_01 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 Local buffer xstats_map is not released, when the xstats name passed by the user application is not valid. This patch releases the memory in such cases. Fixes: 4ff4ab8e1a20 ("ml/cnxk: support extended statistics") Signed-off-by: Srikanth Yalavarthi --- drivers/ml/cnxk/cn10k_ml_ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c index 8d31276e8c..4df2ca0e8c 100644 --- a/drivers/ml/cnxk/cn10k_ml_ops.c +++ b/drivers/ml/cnxk/cn10k_ml_ops.c @@ -1128,8 +1128,10 @@ cn10k_ml_dev_xstats_by_name_get(struct rte_ml_dev *dev, const char *name, uint16 } } - if (id == PLT_DIM(cn10k_ml_model_xstats_table) * dev_info.max_models) + if (id == PLT_DIM(cn10k_ml_model_xstats_table) * dev_info.max_models) { + rte_free(xstats_map); return -EINVAL; + } model_id = id / PLT_DIM(cn10k_ml_model_xstats_table); type = id % PLT_DIM(cn10k_ml_model_xstats_table); -- 2.17.1