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]
Date:	Wed, 16 Jul 2014 17:26:39 +0300
From:	Adrian Hunter <adrian.hunter@...el.com>
To:	Jiri Olsa <jolsa@...hat.com>
CC:	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org, David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Namhyung Kim <namhyung@...il.com>,
	Paul Mackerras <paulus@...ba.org>,
	Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 12/41] perf tools: Fix leak of 'struct thread' on error
 path

On 16/07/2014 5:02 p.m., Jiri Olsa wrote:
> On Mon, Jul 14, 2014 at 01:02:36PM +0300, Adrian Hunter wrote:
>> __machine__findnew_thread() creates a 'struct thread'
>> but does not free it on the error path.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
>> ---
>>   tools/perf/util/machine.c | 4 +++-
>>   tools/perf/util/thread.c  | 6 ++++--
>>   2 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
>> index c1c5ca3..18eaf31 100644
>> --- a/tools/perf/util/machine.c
>> +++ b/tools/perf/util/machine.c
>> @@ -349,8 +349,10 @@ static struct thread *__machine__findnew_thread(struct machine *machine,
>>   		 * within thread__init_map_groups to find the thread
>>   		 * leader and that would screwed the rb tree.
>>   		 */
>> -		if (thread__init_map_groups(th, machine))
>> +		if (thread__init_map_groups(th, machine)) {
>> +			thread__delete(th);
>>   			return NULL;
>> +		}
>>   	}
>>
>>   	return th;
>> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
>> index 149e417..b9a3ee4 100644
>> --- a/tools/perf/util/thread.c
>> +++ b/tools/perf/util/thread.c
>> @@ -95,8 +95,10 @@ void thread__delete(struct thread *thread)
>>   {
>>   	struct comm *comm, *tmp;
>>
>> -	map_groups__put(thread->mg);
>> -	thread->mg = NULL;
>> +	if (thread->mg) {
>> +		map_groups__put(thread->mg);
>> +		thread->mg = NULL;
>> +	}
>
> I dont think this is ^^^ needed..  each thread has ->mg defined

On the error path the thread does not yet have an mg.
--
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