linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hewenliang <hewenliang4@huawei.com>
To: <rostedt@goodmis.org>, <acme@redhat.com>, <tstoyanov@vmware.com>,
	<linux-kernel@vger.kernel.org>
Cc: <linfeilong@huawei.com>
Subject: [PATCH] tools lib traceevent: Fix memory leakage in filter_event
Date: Mon, 9 Dec 2019 01:35:49 -0500	[thread overview]
Message-ID: <20191209063549.59941-1-hewenliang4@huawei.com> (raw)

It is necessary to call free_arg(arg) when add_filter_type returns NULL in
the function of filter_event.

Signed-off-by: Hewenliang <hewenliang4@huawei.com>
---
 tools/lib/traceevent/parse-filter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index f3cbf86e51ac..20eed719542e 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1228,8 +1228,10 @@ filter_event(struct tep_event_filter *filter, struct tep_event *event,
 	}
 
 	filter_type = add_filter_type(filter, event->id);
-	if (filter_type == NULL)
+	if (filter_type == NULL) {
+		free_arg(arg);
 		return TEP_ERRNO__MEM_ALLOC_FAILED;
+	}
 
 	if (filter_type->filter)
 		free_arg(filter_type->filter);
-- 
2.19.1


             reply	other threads:[~2019-12-09  6:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09  6:35 Hewenliang [this message]
2019-12-20  1:56 ` [PATCH] tools lib traceevent: Fix memory leakage in filter_event Steven Rostedt
2019-12-20 21:47   ` Arnaldo Carvalho de Melo
2019-12-23 21:35 ` [tip: perf/urgent] " tip-bot2 for Hewenliang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191209063549.59941-1-hewenliang4@huawei.com \
    --to=hewenliang4@huawei.com \
    --cc=acme@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tstoyanov@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).