mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Yunfeng Ye <yeyunfeng@huawei.com>,
	peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, namhyung@kernel.org,
	linux-kernel@vger.kernel.org, hushiyuan@huawei.com,
	linfeilong@huawei.com
Subject: Re: [PATCH] perf c2c: fix memory leak in build_cl_output()
Date: Tue, 15 Oct 2019 12:08:39 -0300	[thread overview]
Message-ID: <20191015150839.GC25820@kernel.org> (raw)
In-Reply-To: <20191015084753.GD10951@krava>

Em Tue, Oct 15, 2019 at 10:47:53AM +0200, Jiri Olsa escreveu:
> On Tue, Oct 15, 2019 at 10:54:14AM +0800, Yunfeng Ye wrote:
> > There is a memory leak problem in the failure paths of
> > build_cl_output(), so fix it.
> > 
> > Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied to perf/urgent.

- Arnaldo
 
> thanks,
> jirka
> 
> > ---
> >  tools/perf/builtin-c2c.c | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > index 3542b6a..e69f449 100644
> > --- a/tools/perf/builtin-c2c.c
> > +++ b/tools/perf/builtin-c2c.c
> > @@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
> >  	bool add_sym   = false;
> >  	bool add_dso   = false;
> >  	bool add_src   = false;
> > +	int ret = 0;
> > 
> >  	if (!buf)
> >  		return -ENOMEM;
> > @@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
> >  			add_dso = true;
> >  		} else if (strcmp(tok, "offset")) {
> >  			pr_err("unrecognized sort token: %s\n", tok);
> > -			return -EINVAL;
> > +			ret = -EINVAL;
> > +			goto err;
> >  		}
> >  	}
> > 
> > @@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
> >  		add_sym ? "symbol," : "",
> >  		add_dso ? "dso," : "",
> >  		add_src ? "cl_srcline," : "",
> > -		"node") < 0)
> > -		return -ENOMEM;
> > +		"node") < 0) {
> > +		ret = -ENOMEM;
> > +		goto err;
> > +	}
> > 
> >  	c2c.show_src = add_src;
> > -
> > +err:
> >  	free(buf);
> > -	return 0;
> > +	return ret;
> >  }
> > 
> >  static int setup_coalesce(const char *coalesce, bool no_source)
> > -- 
> > 2.7.4.3
> > 

-- 

- Arnaldo

  reply	other threads:[~2019-10-15 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  2:54 Yunfeng Ye
2019-10-15  8:47 ` Jiri Olsa
2019-10-15 15:08   ` Arnaldo Carvalho de Melo [this message]
2019-10-21  6:26 ` [tip: perf/urgent] perf c2c: Fix " tip-bot2 for Yunfeng Ye

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=20191015150839.GC25820@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hushiyuan@huawei.com \
    --cc=jolsa@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yeyunfeng@huawei.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

Powered by JetHome