lkml.org 
[lkml]   [2014]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/8] perf tools: free aliases[j] in pmu.c if name_only is true.
On 01/08/2014 10:12 AM, Arnaldo Carvalho de Melo wrote:
> What for? Please be clear in the changelogs, it helps with review.
>
> Now I'll have to follow the logic to figure this out, i.e. _why_ we
> should free aliases[j] if name_only is true? Is it safe?

Sorry for my lazy on the changelogs here :(.

As aliases is a 2-D array malloced in function print_pmu_events(), we
should free it after printf. But we just did it when (!name_only).

This patch fix the leak error in print_pmu_events() when name_only is true.

I will update the commit message in next version.

- Yang
>
> - Arnaldo
>
> Em Mon, Dec 30, 2013 at 10:26:38AM -0500, Dongsheng Yang escreveu:
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>> tools/perf/util/pmu.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>> index 331dc2c..169c480 100644
>> --- a/tools/perf/util/pmu.c
>> +++ b/tools/perf/util/pmu.c
>> @@ -752,6 +752,7 @@ unsigned int print_pmu_events(const char *event_glob, bool name_only)
>> for (j = 0; j < len; j++) {
>> if (name_only) {
>> printf("%s ", aliases[j]);
>> + zfree(&aliases[j]);
>> count++;
>> continue;
>> }
>> --
>> 1.8.2.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>



\
 
 \ /
  Last update: 2014-01-09 03:41    [W:0.052 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site