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 057A1A0540 for ; Wed, 21 Sep 2022 14:04:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 052D842B72; Wed, 21 Sep 2022 14:04:29 +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 79EEC42B71 for ; Wed, 21 Sep 2022 14:04:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663761868; 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=ie4ErHtAOTxi7CocibWj7IWY8g7SuoaqA/pnwU0eV2A=; b=YEAq2wHPBt4jIEagQZDLgC4nk1IPvultHKd8mSYtJDfuaGNLzqRK8JkRX/qWNO2+u3b88J xbJSASGn1cZd7G2MMUwl7NbYhQW4PYmj2nsTr9m+aCl/2fdQlIbRs+V/2VvZX41Cj+zKrQ PR6gQeg1w3TGtCDyKwYydbODpbcaxQ8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-150-vZZ7w1UlPVSG6imEqy-K9A-1; Wed, 21 Sep 2022 08:04:22 -0400 X-MC-Unique: vZZ7w1UlPVSG6imEqy-K9A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BAF21C1A951; Wed, 21 Sep 2022 12:04:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E3502027063; Wed, 21 Sep 2022 12:04:21 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Jerin Jacob , Sunil Kumar Kori Subject: [PATCH 3/8] trace: fix leak with regexp Date: Wed, 21 Sep 2022 14:03:54 +0200 Message-Id: <20220921120359.2201131-4-david.marchand@redhat.com> In-Reply-To: <20220921120359.2201131-1-david.marchand@redhat.com> References: <20220921120359.2201131-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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 --- lib/eal/common/eal_common_trace.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index 1db28a441d..c835b0d16e 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -210,15 +210,18 @@ rte_trace_regexp(const char *regex, bool enable) return -EINVAL; STAILQ_FOREACH(tp, &tp_list, next) { - if (regexec(&r, tp->name, 0, NULL, 0) == 0) { - if (enable) - rc = rte_trace_point_enable(tp->handle); - else - rc = rte_trace_point_disable(tp->handle); - found = 1; + if (regexec(&r, tp->name, 0, NULL, 0) != 0) + continue; + + if (enable) + rc = rte_trace_point_enable(tp->handle); + else + rc = rte_trace_point_disable(tp->handle); + if (rc < 0) { + found = 0; + break; } - if (rc < 0) - return rc; + found = 1; } regfree(&r); -- 2.37.3