linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: He Kuang <hekuang@huawei.com>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	<acme@kernel.org>, <mingo@redhat.com>, <a.p.zijlstra@chello.nl>,
	"namhyung@kernel.org >> Namhyung Kim" <namhyung@kernel.org>
Cc: <wangnan0@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf tools: Fix possible double free on error
Date: Tue, 10 Mar 2015 11:35:58 +0800	[thread overview]
Message-ID: <54FE669E.10903@huawei.com> (raw)
In-Reply-To: <54F6FEBF.40504@hitachi.com>

Hi,

It seems this patch not appeared in any repo, so ping..

On 2015/3/4 20:46, Masami Hiramatsu wrote:
> (2015/03/04 19:01), He Kuang wrote:
>> A double free occurred when get source file path failed. If lr->path
>> failed to assign a new value, it will be freed as the old path and then
>> be freed again during line_range__clear(), and causes this:
>>
>>    $ perf probe -L do_execve -k vmlinux
>>    *** Error in `/usr/bin/perf': double free or corruption (fasttop):
>>        0x0000000000a9ac50 ***
>>    ======= Backtrace: =========
>>    ../lib64/libc.so.6(+0x6eeef)[0x7ffff5e44eef]
>>    ../lib64/libc.so.6(+0x78cae)[0x7ffff5e4ecae]
>>    ../lib64/libc.so.6(+0x79987)[0x7ffff5e4f987]
>>    ../bin/perf[0x4ab41f]
>>    ...
>>
>> This patch fix this problem.
> Good catch!
>
> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>
> Thank you,
>
>> Signed-off-by: He Kuang <hekuang@huawei.com>
>> ---
>>   tools/perf/util/probe-event.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
>> index 919937e..7df30bd 100644
>> --- a/tools/perf/util/probe-event.c
>> +++ b/tools/perf/util/probe-event.c
>> @@ -650,7 +650,11 @@ static int __show_line_range(struct line_range *lr, const char *module)
>>   	/* Convert source file path */
>>   	tmp = lr->path;
>>   	ret = get_real_path(tmp, lr->comp_dir, &lr->path);
>> -	free(tmp);	/* Free old path */
>> +
>> +	/* Free old path when new path is assigned */
>> +	if (tmp != lr->path)
>> +		free(tmp);
>> +
>>   	if (ret < 0) {
>>   		pr_warning("Failed to find source file path.\n");
>>   		return ret;
>>
>



  reply	other threads:[~2015-03-10  3:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 10:01 [PATCH] perf tools: Fix possible double free on error He Kuang
2015-03-04 12:46 ` Masami Hiramatsu
2015-03-10  3:35   ` He Kuang [this message]
2015-03-14  7:04 ` [tip:perf/core] perf probe: " tip-bot for He Kuang

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=54FE669E.10903@huawei.com \
    --to=hekuang@huawei.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@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;
as well as URLs for NNTP newsgroup(s).