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] [thread-next>] [day] [month] [year] [list]
Message-ID: <87y4usdg3v.fsf@sejong.aot.lge.com>
Date:	Wed, 13 Aug 2014 16:05:24 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Adrian Hunter <adrian.hunter@...el.com>
Cc:	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Namhyung Kim <namhyung.kim@....com>,
	LKML <linux-kernel@...r.kernel.org>,
	Jiri Olsa <jolsa@...hat.com>, David Ahern <dsahern@...il.com>,
	Minchan Kim <minchan@...nel.org>
Subject: Re: [PATCH 01/13] perf script: Fix possible memory leaks

On Wed, 13 Aug 2014 09:21:31 +0300, Adrian Hunter wrote:
> On 08/12/2014 09:40 AM, Namhyung Kim wrote:
>>  		input = open(file.path, O_RDONLY);	/* input_name */
>>  		if (input < 0) {
>>  			perror("failed to open file");
>> -			return -1;
>> +			err = -errno;
>
> Need to get errno before calling perror().

Argh, right.

>
>> +			goto out_delete;
>>  		}
>>  
>>  		err = fstat(input, &perf_stat);
>>  		if (err < 0) {
>>  			perror("failed to stat file");
>> -			return -1;
>> +			goto out_delete;
>>  		}
>>  
>>  		if (!perf_stat.st_size) {
>>  			fprintf(stderr, "zero-sized file, nothing to do!\n");
>> -			return 0;
>> +			goto out_delete;
>>  		}
>>  
>>  		scripting_ops = script_spec__lookup(generate_script_lang);
>>  		if (!scripting_ops) {
>>  			fprintf(stderr, "invalid language specifier");
>> -			return -1;
>> +			err = -ENOENT;
>> +			goto out_delete;
>>  		}
>>  
>>  		err = scripting_ops->generate_script(session->tevent.pevent,
>>  						     "perf-script");
>> -		goto out;
>> +		goto out_delete;
>>  	}
>>  
>>  	if (script_name) {
>>  		err = scripting_ops->start_script(script_name, argc, argv);
>>  		if (err)
>> -			goto out;
>> +			goto out_delete;
>>  		pr_debug("perf script started with script %s\n\n", script_name);
>> +		script_started = true;
>>  	}
>>  
>>  
>>  	err = perf_session__check_output_opt(session);
>>  	if (err < 0)
>> -		goto out;
>> +		goto out_delete;
>>  
>>  	err = __cmd_script(&script);
>>  
>> +out_delete:
>
> I added a flush method in a patch which acme has stashed in his
> tmp.perf/core branch.  It would go here:
>
> 	if (script_started)
> 		flush_scripting();

Thanks for the info.  I'll update once it's merged into acme/perf/core.

Thanks,
Namhyung


>
>>  	perf_session__delete(session);
>> -	cleanup_scripting();
>> +
>> +	if (script_started)
>> +		cleanup_scripting();
>>  out:
>>  	return err;
>>  }
>> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ