lkml.org 
[lkml]   [2015]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] perf probe: Clear probe_trace_event when probe_trace_event failure
Date
From: Wang Nan [mailto:wangnan0@huawei.com]
>
>When failure occures in add_probe_trace_event(), to avoid potential
>dangling pointer and memory leak, resource attached to 'struct
>probe_trace_event' should be cleared.

Oops, right. I've found actual memory leak and this fix is not enough,
because debuginfo__find_trace_events() releases "tevs" array without
clearing everything in the array if it fails...

Since add_probe_trace_event() may be invoked repeatedly while searching
probe points from debuginfo, there can be the case that first N-1 times
succeeds, but Nth call fails. In that case, even if you clear the last
one, we still have N-1 tevs and debuginfo__find_trace_events() leaks those.
Thus, the correct fix is clearing all the tevs when we hit any error.

I'll send other patch to fix it.

Thanks!

>
>Signed-off-by: Wang Nan <wangnan0@huawei.com>
>Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
>Cc: Zefan Li <lizefan@huawei.com>
>Cc: pi3orama@163.com
>---
> tools/perf/util/probe-finder.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
>index bd8f03d..e9e37ca 100644
>--- a/tools/perf/util/probe-finder.c
>+++ b/tools/perf/util/probe-finder.c
>@@ -1235,6 +1235,8 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
>
> end:
> free(args);
>+ if (ret)
>+ clear_probe_trace_event(tev);
> return ret;
> }
>
>--
>1.8.3.4

\
 
 \ /
  Last update: 2015-11-11 16:01    [W:0.037 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site