perf probe: Fix to free temporal Dwarf_Frame
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Wed, 18 Nov 2015 06:40:12 +0000 (15:40 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 19 Nov 2015 16:19:17 +0000 (13:19 -0300)
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>
tools/perf/util/probe-finder.c

index 05012bb178d7a8d75ebf4879438fbc0d6f774926..1cab05a3831e65c25a3fa0e11650b4eb11a02b9a 100644 (file)
@@ -683,21 +683,24 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
        ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
        if (ret <= 0 || nops == 0) {
                pf->fb_ops = NULL;
+               ret = 0;
 #if _ELFUTILS_PREREQ(0, 142)
        } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa &&
                   pf->cfi != NULL) {
-               Dwarf_Frame *frame;
+               Dwarf_Frame *frame = NULL;
                if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 ||
                    dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) {
                        pr_warning("Failed to get call frame on 0x%jx\n",
                                   (uintmax_t)pf->addr);
-                       return -ENOENT;
+                       ret = -ENOENT;
                }
+               free(frame);
 #endif
        }
 
        /* Call finder's callback handler */
-       ret = pf->callback(sc_die, pf);
+       if (ret >= 0)
+               ret = pf->callback(sc_die, pf);
 
        /* *pf->fb_ops will be cached in libdw. Don't free it. */
        pf->fb_ops = NULL;
This page took 0.031455 seconds and 5 git commands to generate.