Skip to content

Commit 05c8d80

Browse files
mhiramathitachiacmel
authored andcommitted
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>
1 parent 5bcf2fe commit 05c8d80

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎tools/perf/util/probe-finder.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,21 +683,24 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
683683
ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
684684
if (ret <= 0 || nops == 0) {
685685
pf->fb_ops = NULL;
686+
ret = 0;
686687
#if _ELFUTILS_PREREQ(0, 142)
687688
} else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa &&
688689
pf->cfi != NULL) {
689-
Dwarf_Frame *frame;
690+
Dwarf_Frame *frame = NULL;
690691
if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 ||
691692
dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) {
692693
pr_warning("Failed to get call frame on 0x%jx\n",
693694
(uintmax_t)pf->addr);
694-
return -ENOENT;
695+
ret = -ENOENT;
695696
}
697+
free(frame);
696698
#endif
697699
}
698700

699701
/* Call finder's callback handler */
700-
ret = pf->callback(sc_die, pf);
702+
if (ret >= 0)
703+
ret = pf->callback(sc_die, pf);
701704

702705
/* *pf->fb_ops will be cached in libdw. Don't free it. */
703706
pf->fb_ops = NULL;

0 commit comments

Comments
 (0)