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 EE9E1A0A0E;
	Tue, 11 May 2021 13:34:29 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id D23CC410ED;
	Tue, 11 May 2021 13:34:29 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [216.205.24.124])
 by mails.dpdk.org (Postfix) with ESMTP id 6C9954003E
 for <dev@dpdk.org>; Tue, 11 May 2021 13:34:28 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1620732867;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=9d1v5jY+OAab8uvYoT5RTBR28NWuxq2kq6P6VuiP5/A=;
 b=g2SwuFekmHlKJHM9h8cgUJp+q2UEs3x9Ft3ukENPx1DqMK/AzhmmT0qbthIy5y72U9UeML
 OdgnOTXCtC0oBHUebI3rffFyYYJPgEZeVWhJRpHPV+K74VqcbS1g1tP6aNU8HzU2WcKC3I
 TwDBNXqk0POP4qsr0/DZeE10yMsEgK0=
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com
 [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id
 us-mta-395-6E-9OyC8NuuNkhW1stmqvA-1; Tue, 11 May 2021 07:34:24 -0400
X-MC-Unique: 6E-9OyC8NuuNkhW1stmqvA-1
Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com
 [10.5.11.16])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24C7BDF8A4;
 Tue, 11 May 2021 11:34:23 +0000 (UTC)
Received: from dmarchan.remote.csb (unknown [10.40.192.60])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 488751725E;
 Tue, 11 May 2021 11:34:19 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: timothy.mcdaniel@intel.com, maxime.coquelin@redhat.com,
 chenbo.xia@intel.com, stable@dpdk.org,
 Shepard Siegel <shepard.siegel@atomicrules.com>,
 Ed Czeck <ed.czeck@atomicrules.com>,
 John Miller <john.miller@atomicrules.com>
Date: Tue, 11 May 2021 13:33:57 +0200
Message-Id: <20210511113358.2485-2-david.marchand@redhat.com>
In-Reply-To: <20210511113358.2485-1-david.marchand@redhat.com>
References: <20210506094452.1689-1-david.marchand@redhat.com>
 <20210511113358.2485-1-david.marchand@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16
Authentication-Results: relay.mimecast.com;
 auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"
Subject: [dpdk-dev] [PATCH v2 1/2] net/ark: fix leak on thread termination
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
Sender: "dev" <dev-bounces@dpdk.org>

A terminated pthread should be joined or detached so that its associated
resources are released.

The "ark-delay-pg" thread is just used to delay some task but it is never
joined by the thread that created it.
The easiest solution is to detach the new thread.

Fixes: 727b3fe292bc ("net/ark: integrate PMD")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/ark/ark_pktgen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 28a44f7546..515bfe461c 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -3,6 +3,7 @@
  */
 
 #include <unistd.h>
+#include <pthread.h>
 
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
@@ -474,6 +475,7 @@ ark_pktgen_delay_start(void *arg)
 	 * perform a blind sleep here to ensure that the external test
 	 * application has time to setup the test before we generate packets
 	 */
+	pthread_detach(pthread_self());
 	usleep(100000);
 	ark_pktgen_run(inst);
 	return NULL;
-- 
2.23.0