lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 3 Jun 2020 11:03:20 +0800
From:   "LiBin (Huawei)" <huawei.libin@...wei.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Wei Li <liwei391@...wei.com>
CC:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Namhyung Kim <namhyung@...nel.org>,
        <linux-kernel@...r.kernel.org>, Xie XiuQi <xiexiuqi@...wei.com>,
        Hongbo Yao <yaohongbo@...wei.com>
Subject: Re: [PATCH 2/4] perf svghelper: Fix memory leak in
 svg_build_topology_map


在 2020/5/21 22:15, Arnaldo Carvalho de Melo 写道:
> Em Thu, May 21, 2020 at 09:32:16PM +0800, Wei Li escreveu:
>> From: Li Bin <huawei.libin@...wei.com>
>>
>> Fix leak of memory pointed to by t.sib_thr and t.sib_core in
>> svg_build_topology_map.
>>
>> Signed-off-by: Li Bin <huawei.libin@...wei.com>
>> ---
>>   tools/perf/util/svghelper.c | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
>> index 96f941e01681..e2b3b0e2fafe 100644
>> --- a/tools/perf/util/svghelper.c
>> +++ b/tools/perf/util/svghelper.c
>> @@ -754,6 +754,7 @@ int svg_build_topology_map(struct perf_env *env)
>>   	int i, nr_cpus;
>>   	struct topology t;
>>   	char *sib_core, *sib_thr;
>> +	int ret;
> Please set ret to -1 here
>
> 	int ret = -1;
> 	
> So that you don't have to add all those lines below...
>
>>   
>>   	nr_cpus = min(env->nr_cpus_online, MAX_NR_CPUS);
>>   
>> @@ -767,12 +768,14 @@ int svg_build_topology_map(struct perf_env *env)
>>   
>>   	if (!t.sib_core || !t.sib_thr) {
>>   		fprintf(stderr, "topology: no memory\n");
>> +		ret = -1;
>>   		goto exit;
>>   	}
>>   
>>   	for (i = 0; i < env->nr_sibling_cores; i++) {
>>   		if (str_to_bitmap(sib_core, &t.sib_core[i], nr_cpus)) {
>>   			fprintf(stderr, "topology: can't parse siblings map\n");
>> +			ret = -1;
>>   			goto exit;
>>   		}
>>   
>> @@ -782,6 +785,7 @@ int svg_build_topology_map(struct perf_env *env)
>>   	for (i = 0; i < env->nr_sibling_threads; i++) {
>>   		if (str_to_bitmap(sib_thr, &t.sib_thr[i], nr_cpus)) {
>>   			fprintf(stderr, "topology: can't parse siblings map\n");
>> +			ret = -1;
>>   			goto exit;
>>   		}
>>   
>> @@ -791,6 +795,7 @@ int svg_build_topology_map(struct perf_env *env)
>>   	topology_map = malloc(sizeof(int) * nr_cpus);
>>   	if (!topology_map) {
>>   		fprintf(stderr, "topology: no memory\n");
>> +		ret = -1;
>>   		goto exit;
>>   	}
>>   
>> @@ -798,12 +803,11 @@ int svg_build_topology_map(struct perf_env *env)
>>   		topology_map[i] = -1;
>>   
>>   	scan_core_topology(topology_map, &t, nr_cpus);
>> -
>> -	return 0;
> ... as you'll set it to zero here :-)


Thank you for your comments. I will fix it.

Thanks,

Li Bin


>> +	ret = 0;
>>   
>>   exit:
>>   	zfree(&t.sib_core);
>>   	zfree(&t.sib_thr);
>>   
>> -	return -1;
>> +	return ret;
>>   }
>> -- 
>> 2.17.1
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ