linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/4] trace-cmd traceevent: Fix memory leakage in filter_event
Date: Mon, 22 Jun 2020 10:45:52 +0300	[thread overview]
Message-ID: <20200622074554.151747-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20200622074554.151747-1-tz.stoyanov@gmail.com>

From: Hewenliang <hewenliang4@huawei.com>

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

Signed-off-by: Hewenliang <hewenliang4@huawei.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Feilong Lin <linfeilong@huawei.com>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Link: http://lore.kernel.org/lkml/20191209063549.59941-1-hewenliang4@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 lib/traceevent/parse-filter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/traceevent/parse-filter.c b/lib/traceevent/parse-filter.c
index f3cbf86e..20eed719 100644
--- a/lib/traceevent/parse-filter.c
+++ b/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.26.2


  parent reply	other threads:[~2020-06-22  7:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22  7:45 [PATCH 0/4] Synchronize libtraceevent with kernel tree Tzvetomir Stoyanov (VMware)
2020-06-22  7:45 ` [PATCH 1/4] trace-cmd libtraceevent: Remove unneeded semicolon Tzvetomir Stoyanov (VMware)
2020-06-22  7:45 ` Tzvetomir Stoyanov (VMware) [this message]
2020-06-22  7:45 ` [PATCH 3/4] trace-cmd: traceevent: Take care of return value of asprintf Tzvetomir Stoyanov (VMware)
2020-06-22  7:45 ` [PATCH 4/4] trace-cmd traceevent: update KVM plugin Tzvetomir Stoyanov (VMware)
2020-06-22 13:44 ` [PATCH 0/4] Synchronize libtraceevent with kernel tree Steven Rostedt

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=20200622074554.151747-3-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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).