All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Hewenliang <hewenliang4@huawei.com>, <acme@redhat.com>
Cc: <tstoyanov@vmware.com>, <namhyung@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linfeilong@huawei.com>
Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
Date: Wed, 13 Nov 2019 14:47:57 -0500	[thread overview]
Message-ID: <20191113144757.2c4ca83b@gandalf.local.home> (raw)
In-Reply-To: <20191113144626.44ad5418@gandalf.local.home>

On Wed, 13 Nov 2019 14:46:26 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Fri, 25 Oct 2019 04:23:12 -0400
> Hewenliang <hewenliang4@huawei.com> wrote:
> 
> > It is necessary to free the memory that we have allocated
> > when error occurs.
> > 
> > Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> > Signed-off-by: Hewenliang <hewenliang4@huawei.com>  
> 
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

After I sent this, I found an issue.

> 
> Arnaldo,
> 
> Can you take this?

Don't take it.

> 
> > ---
> >  tools/lib/traceevent/parse-filter.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> > index 552592d153fb..fbaa790d10d8 100644
> > --- a/tools/lib/traceevent/parse-filter.c
> > +++ b/tools/lib/traceevent/parse-filter.c
> > @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> >  	if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> >  		/* Add trivial event */
> >  		arg = allocate_arg();
> > -		if (arg == NULL)
> > +		if (arg == NULL) {
> > +			free(str);
> >  			return -1;
> > +		}
> >  
> >  		arg->type = TEP_FILTER_ARG_BOOLEAN;
> >  		if (strcmp(str, "TRUE") == 0)
> > @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> >  			arg->boolean.value = 0;
> >  
> >  		filter_type = add_filter_type(filter, event->id);
> > -		if (filter_type == NULL)
> > +		if (filter_type == NULL) {
> > +			free(str);
> > +			free(arg);

This needs to be: free_arg(arg);

-- Steve

> >  			return -1;
> > +		}
> >  
> >  		filter_type->filter = arg;
> >    
> 


  reply	other threads:[~2019-11-13 19:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  8:23 [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type Hewenliang
2019-11-13 19:46 ` Steven Rostedt
2019-11-13 19:47   ` Steven Rostedt [this message]
2019-11-13 20:37   ` Arnaldo Carvalho de Melo
2019-11-13 20:40     ` Steven Rostedt
2019-11-13 23:01       ` Arnaldo Carvalho de Melo
2019-11-18  3:42       ` Hewenliang
2019-11-19  1:44       ` [PATCH v2] " Hewenliang
2019-11-21 14:43         ` Arnaldo Carvalho de Melo
2019-11-23  8:15         ` [tip: perf/core] libtraceevent: " tip-bot2 for Hewenliang
2019-11-18 14:28 ` [PATCH v2] tools lib traceevent: " Steven Rostedt
2019-11-18 15:24   ` Arnaldo Carvalho de Melo

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=20191113144757.2c4ca83b@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=acme@redhat.com \
    --cc=hewenliang4@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.