From: Wang Nan [mailto:[email protected]] > >When failure occures in add_probe_trace_event(), args in >probe_trace_event is incomplete. Since information in it may be used >in futher, this patch frees the allocated memory and set it to NULL >to avoid dangling pointer.
Sorry for replying late. Please see my comment. > >Signed-off-by: Wang Nan <[email protected]> >Cc: Alexei Starovoitov <[email protected]> >Cc: Brendan Gregg <[email protected]> >Cc: Daniel Borkmann <[email protected]> >Cc: David Ahern <[email protected]> >Cc: He Kuang <[email protected]> >Cc: Jiri Olsa <[email protected]> >Cc: Kaixu Xia <[email protected]> >Cc: Masami Hiramatsu <[email protected]> >Cc: Namhyung Kim <[email protected]> >Cc: Paul Mackerras <[email protected]> >Cc: Peter Zijlstra <[email protected]> >Cc: Zefan Li <[email protected]> >Cc: [email protected] >Cc: Arnaldo Carvalho de Melo <[email protected]> >Link: http://lkml.kernel.org/n/[email protected] >--- > tools/perf/util/probe-finder.c | 4 ++++ > 1 file changed, 4 insertions(+) > >diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c >index bd8f03d..b1581d7 100644 >--- a/tools/perf/util/probe-finder.c >+++ b/tools/perf/util/probe-finder.c >@@ -1235,6 +1235,10 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, >struct probe_finder *pf) > > end: > free(args); Actually, this args is filled with constant strings allocated in libdw, so it doesn't free args[*].vars. >+ if (ret) { >+ tev->nargs = 0; >+ zfree(&tev->args); However, all the fields in tev->args[*] are allocated in find_variables. If you'd like to clear it, you must free the fields too. So, you should call clear_probe_trace_event(struct probe_trace_event *tev) defined in util/probe-event.c. Thank you, >+ } > return ret; > } > >-- >1.8.3.4

