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 B43B4A0543;
	Tue,  4 Oct 2022 11:44:50 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id A7EF8427EE;
	Tue,  4 Oct 2022 11:44:50 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id C5D9740DDC
 for <dev@dpdk.org>; Tue,  4 Oct 2022 11:44:48 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1664876688;
 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=63bHYDv5gpR/bhH6+pbiddRy1p6D9eaYoHUJfOjn0w0=;
 b=YPozipHygqjkZIL5jDLRccVSRBlHBzfHTJrSXqxmrbX+kRBeO0U+Na4CoVXXEVLEi/FwgA
 S13RZpudrROLMQFORsGPBFadlUMKyYvFCuoiz7CJS2Gd2xJDHvdAyX++KI+qICXIUqujwB
 ik/nujCiEhso/CqMY7dB0xBgR4iMTm4=
Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com
 [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 us-mta-166-ArrxOI5KOQ2EhymZvLoR8A-1; Tue, 04 Oct 2022 05:44:45 -0400
X-MC-Unique: ArrxOI5KOQ2EhymZvLoR8A-1
Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com
 [10.11.54.7])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0E3A87B2A2;
 Tue,  4 Oct 2022 09:44:44 +0000 (UTC)
Received: from localhost.localdomain (unknown [10.40.195.42])
 by smtp.corp.redhat.com (Postfix) with ESMTP id AEE6F140EBF3;
 Tue,  4 Oct 2022 09:44:43 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: skori@mavell.com, jerinj@marvell.com, stable@dpdk.org,
 Sunil Kumar Kori <skori@marvell.com>
Subject: [PATCH v2 3/9] trace: fix leak with regexp
Date: Tue,  4 Oct 2022 11:44:12 +0200
Message-Id: <20221004094418.196544-4-david.marchand@redhat.com>
In-Reply-To: <20221004094418.196544-1-david.marchand@redhat.com>
References: <20220921120359.2201131-1-david.marchand@redhat.com>
 <20221004094418.196544-1-david.marchand@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"; x-default=true
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

The precompiled buffer initialised in regcomp must be freed before
leaving rte_trace_regexp.

Fixes: 84c4fae4628f ("trace: implement operation APIs")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,

---
 lib/eal/common/eal_common_trace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 1b86f5d2d2..1db11e3e14 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable)
 				rc = rte_trace_point_disable(tp->handle);
 			found = 1;
 		}
-		if (rc < 0)
-			return rc;
+		if (rc < 0) {
+			found = 0;
+			break;
+		}
 	}
 	regfree(&r);
 
-- 
2.37.3