From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id EB02345C14;
	Wed, 30 Oct 2024 13:13:05 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id BD9794332E;
	Wed, 30 Oct 2024 13:13:05 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com
 [67.231.156.173])
 by mails.dpdk.org (Postfix) with ESMTP id 58E324331C
 for <dev@dpdk.org>; Wed, 30 Oct 2024 13:13:04 +0100 (CET)
Received: from pps.filterd (m0431383.ppops.net [127.0.0.1])
 by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UB9BWb015545;
 Wed, 30 Oct 2024 05:12:53 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=
 cc:content-transfer-encoding:content-type:date:from:message-id
 :mime-version:subject:to; s=pfpt0220; bh=Qna+Tl4Us8yV2mGu69Z0Q+o
 RwNGhZqpD/aOsuKM1n9M=; b=bWIRNPAJVuM5o2Vta9LIUlsUhIGUt7ASp4yG6Pp
 FbPTfQYCKNLQjd8WIqz9gyx1Mk4CtZeXL5eIz7+lgdh+vKQZTBqsOxBttbC98IF1
 fcamlG1UG6lZ2vZ1ePdynavoqizyLGTruVAtBjJeqiosFYqoAF+z8Sq3leLvCnhC
 8dqKDiGh4u1CpKZTuiFyTiE39QBkATf6uoArLwpmuz0F0EMBmfyOdmhhOL0lUCAD
 tUhWNd4lrbtrT9VD5b1yLH1ZTyWUFpfkwJQOPHUivqFUizQk5dV3+Lvo4uhHwYZs
 aTml6Wlbfm5SRa+gltjmTJasHMr/BBIggyAdc9StDkv/aCA==
Received: from dc5-exch05.marvell.com ([199.233.59.128])
 by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42kdenrw2j-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);
 Wed, 30 Oct 2024 05:12:53 -0700 (PDT)
Received: from DC5-EXCH05.marvell.com (10.69.176.209) by
 DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.2.1544.4; Wed, 30 Oct 2024 05:12:51 -0700
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com
 (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend
 Transport; Wed, 30 Oct 2024 05:12:51 -0700
Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com
 [10.28.164.106])
 by maili.marvell.com (Postfix) with ESMTP id CD2E85E6870;
 Wed, 30 Oct 2024 05:12:49 -0700 (PDT)
From: <pbhagavatula@marvell.com>
To: <jerinj@marvell.com>, Kiran Kumar K <kirankumark@marvell.com>, "Nithin
 Dabilpuram" <ndabilpuram@marvell.com>, Zhirun Yan <yanzhirun_163@163.com>
CC: <dev@dpdk.org>, Pavan Nikhilesh <pbhagavatula@marvell.com>
Subject: [PATCH] graph: fix memory leak in node clone
Date: Wed, 30 Oct 2024 17:42:47 +0530
Message-ID: <20241030121247.1400-1-pbhagavatula@marvell.com>
X-Mailer: git-send-email 2.25.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-GUID: cKDmExrVHYVonAF3pzidWFxHYyFlc2DX
X-Proofpoint-ORIG-GUID: cKDmExrVHYVonAF3pzidWFxHYyFlc2DX
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475
 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Free memory allocated for the node when xstats memory
allocation fails.

Coverity issue: 445529
Fixes: 070db97e017b ("graph: support node xstats")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 lib/graph/node.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/graph/node.c b/lib/graph/node.c
index f15922892e..eb685b409f 100644
--- a/lib/graph/node.c
+++ b/lib/graph/node.c
@@ -156,7 +156,7 @@ node_clone(struct node *node, const char *name)
 				     (node->xstats->nb_xstats * RTE_NODE_XSTAT_DESC_SIZE));
 		if (reg->xstats == NULL) {
 			rte_errno = ENOMEM;
-			goto fail;
+			goto free;
 		}
 
 		for (i = 0; i < node->xstats->nb_xstats; i++)
-- 
2.25.1
There is one more place in the node_clone function that needs to be modified:
if (clone_name(reg->name, node->name, name)) //goto free;
goto free_xstat;