diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2015-11-18 01:40:12 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-19 11:19:17 -0500 |
commit | 05c8d802fa52ef17dbcce21c38b72b4a313eb036 (patch) | |
tree | 0b1f57e71350b3a98af95d06966e684722c8efe7 /tools/perf | |
parent | 5bcf2fe05318deb6fec209b4028d8a31f9f47221 (diff) |
perf probe: Fix to free temporal Dwarf_Frame
Since dwarf_cfi_addrframe returns malloc'd Dwarf_Frame object, it has to
be freed after it is used.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151118064011.30709.65674.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/probe-finder.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 05012bb178d7..1cab05a3831e 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -683,21 +683,24 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf) | |||
683 | ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); | 683 | ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); |
684 | if (ret <= 0 || nops == 0) { | 684 | if (ret <= 0 || nops == 0) { |
685 | pf->fb_ops = NULL; | 685 | pf->fb_ops = NULL; |
686 | ret = 0; | ||
686 | #if _ELFUTILS_PREREQ(0, 142) | 687 | #if _ELFUTILS_PREREQ(0, 142) |
687 | } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa && | 688 | } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa && |
688 | pf->cfi != NULL) { | 689 | pf->cfi != NULL) { |
689 | Dwarf_Frame *frame; | 690 | Dwarf_Frame *frame = NULL; |
690 | if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 || | 691 | if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 || |
691 | dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) { | 692 | dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) { |
692 | pr_warning("Failed to get call frame on 0x%jx\n", | 693 | pr_warning("Failed to get call frame on 0x%jx\n", |
693 | (uintmax_t)pf->addr); | 694 | (uintmax_t)pf->addr); |
694 | return -ENOENT; | 695 | ret = -ENOENT; |
695 | } | 696 | } |
697 | free(frame); | ||
696 | #endif | 698 | #endif |
697 | } | 699 | } |
698 | 700 | ||
699 | /* Call finder's callback handler */ | 701 | /* Call finder's callback handler */ |
700 | ret = pf->callback(sc_die, pf); | 702 | if (ret >= 0) |
703 | ret = pf->callback(sc_die, pf); | ||
701 | 704 | ||
702 | /* *pf->fb_ops will be cached in libdw. Don't free it. */ | 705 | /* *pf->fb_ops will be cached in libdw. Don't free it. */ |
703 | pf->fb_ops = NULL; | 706 | pf->fb_ops = NULL; |