From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <jianfeng.tan@intel.com>
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 7BA5623B
 for <dev@dpdk.org>; Wed,  2 May 2018 12:24:22 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga008.fm.intel.com ([10.253.24.58])
 by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 02 May 2018 03:24:21 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.49,354,1520924400"; d="scan'208";a="36844723"
Received: from dpdk06.sh.intel.com ([10.67.110.196])
 by fmsmga008.fm.intel.com with ESMTP; 02 May 2018 03:24:20 -0700
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: olivier.matz@6wind.com,
	Jianfeng Tan <jianfeng.tan@intel.com>
Date: Wed,  2 May 2018 10:26:32 +0000
Message-Id: <1525256792-24191-1-git-send-email-jianfeng.tan@intel.com>
X-Mailer: git-send-email 2.7.4
Subject: [dpdk-dev] [PATCH] eal: fix memory leak
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 02 May 2018 10:24:22 -0000

params is not freed if pthread_create() fails. The fix is
straight-forward.

Fixes: 3d09a6e26d8b ("eal: fix threads block on barrier")

Reported-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_eal/common/eal_common_thread.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c
index 5f0c61f..c18a112 100644
--- a/lib/librte_eal/common/eal_common_thread.c
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -183,8 +183,10 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
 	pthread_barrier_init(&params->configured, NULL, 2);
 
 	ret = pthread_create(thread, attr, rte_thread_init, (void *)params);
-	if (ret != 0)
+	if (ret != 0) {
+		free(params);
 		return ret;
+	}
 
 	if (name != NULL) {
 		ret = rte_thread_setname(*thread, name);
-- 
2.7.4