linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: fix for double free in tools/perf stat
@ 2014-10-04 15:37 Yasser Shalabi
  2014-10-07  8:15 ` Namhyung Kim
  2014-10-16  5:23 ` [tip:perf/urgent] perf evlist: Fix for double free in tools/ perf stat tip-bot for Yasser Shalabi
  0 siblings, 2 replies; 4+ messages in thread
From: Yasser Shalabi @ 2014-10-04 15:37 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, mingo, paulus, a.p.zijlstra, Yasser Shalabi

Fix for double free bug in tools/perf due to dangling thread_map pointer in perf_evlist struct.
Code path excercised when perf stat -C switch is used but not set and is followed by another switch.
Example: perf stat -C -e. 
Signed-off-by: Yasser Shalabi <yassershalabi@gmail.com>

---
 tools/perf/util/evlist.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 814e954..09af633 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -845,6 +845,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
 
 out_delete_threads:
 	thread_map__delete(evlist->threads);
+	evlist->threads = 0;
 	return -1;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: fix for double free in tools/perf stat
  2014-10-04 15:37 [PATCH] perf: fix for double free in tools/perf stat Yasser Shalabi
@ 2014-10-07  8:15 ` Namhyung Kim
  2014-10-15 19:17   ` Arnaldo Carvalho de Melo
  2014-10-16  5:23 ` [tip:perf/urgent] perf evlist: Fix for double free in tools/ perf stat tip-bot for Yasser Shalabi
  1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2014-10-07  8:15 UTC (permalink / raw)
  To: Yasser Shalabi; +Cc: acme, linux-kernel, mingo, paulus, a.p.zijlstra

Hi Yasser,

On Sat,  4 Oct 2014 11:37:57 -0400, Yasser Shalabi wrote:
> Fix for double free bug in tools/perf due to dangling thread_map pointer in perf_evlist struct.
> Code path excercised when perf stat -C switch is used but not set and is followed by another switch.
> Example: perf stat -C -e. 
> Signed-off-by: Yasser Shalabi <yassershalabi@gmail.com>
>
> ---
>  tools/perf/util/evlist.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 814e954..09af633 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -845,6 +845,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
>  
>  out_delete_threads:
>  	thread_map__delete(evlist->threads);
> +	evlist->threads = 0;

Nitpick - I think NULL is preferred rather than 0.

Other than that,

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


>  	return -1;
>  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: fix for double free in tools/perf stat
  2014-10-07  8:15 ` Namhyung Kim
@ 2014-10-15 19:17   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-10-15 19:17 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Yasser Shalabi, linux-kernel, mingo, paulus, a.p.zijlstra

Em Tue, Oct 07, 2014 at 05:15:41PM +0900, Namhyung Kim escreveu:
> Hi Yasser,
> 
> On Sat,  4 Oct 2014 11:37:57 -0400, Yasser Shalabi wrote:
> > Fix for double free bug in tools/perf due to dangling thread_map pointer in perf_evlist struct.
> > Code path excercised when perf stat -C switch is used but not set and is followed by another switch.
> > Example: perf stat -C -e. 
> > Signed-off-by: Yasser Shalabi <yassershalabi@gmail.com>
> >
> > ---
> >  tools/perf/util/evlist.c |    1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> > index 814e954..09af633 100644
> > --- a/tools/perf/util/evlist.c
> > +++ b/tools/perf/util/evlist.c
> > @@ -845,6 +845,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
> >  
> >  out_delete_threads:
> >  	thread_map__delete(evlist->threads);
> > +	evlist->threads = 0;
> 
> Nitpick - I think NULL is preferred rather than 0.

yeah, I fixed that.
 
> Other than that,
> 
> Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks, applied!
 
> Thanks,
> Namhyung
> 
> 
> >  	return -1;
> >  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/urgent] perf evlist: Fix for double free in tools/ perf stat
  2014-10-04 15:37 [PATCH] perf: fix for double free in tools/perf stat Yasser Shalabi
  2014-10-07  8:15 ` Namhyung Kim
@ 2014-10-16  5:23 ` tip-bot for Yasser Shalabi
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Yasser Shalabi @ 2014-10-16  5:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, a.p.zijlstra, namhyung, tglx, linux-kernel, yassershalabi,
	paulus, mingo, hpa, acme

Commit-ID:  b2e19a934a36b2b4affcde9c170c0f01afabe50a
Gitweb:     http://git.kernel.org/tip/b2e19a934a36b2b4affcde9c170c0f01afabe50a
Author:     Yasser Shalabi <yassershalabi@gmail.com>
AuthorDate: Sat, 4 Oct 2014 11:37:57 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 15 Oct 2014 16:16:53 -0300

perf evlist: Fix for double free in tools/perf stat

Fix for double free bug in tools/perf due to dangling thread_map pointer
in perf_evlist struct.

Code path excercised when perf stat -C switch is used but not set and is
followed by another switch.

Example:

  perf stat -C -e.

Signed-off-by: Yasser Shalabi <yassershalabi@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1412437077-13109-1-git-send-email-yassershalabi@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b4b54d8..3c9e77d 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1003,6 +1003,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
 
 out_delete_threads:
 	thread_map__delete(evlist->threads);
+	evlist->threads = NULL;
 	return -1;
 }
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-16  5:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-04 15:37 [PATCH] perf: fix for double free in tools/perf stat Yasser Shalabi
2014-10-07  8:15 ` Namhyung Kim
2014-10-15 19:17   ` Arnaldo Carvalho de Melo
2014-10-16  5:23 ` [tip:perf/urgent] perf evlist: Fix for double free in tools/ perf stat tip-bot for Yasser Shalabi

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).