[PATCH -tip 1/5] [BUGFIX] perf-probe: Fix a memory leak for scopesarray

From: Masami Hiramatsu
Date: Sun Jul 10 2011 - 06:42:05 EST


Fix a memory leak for scopes array when it finds a
variable in the global scope.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxxxxxxx>
---

tools/perf/util/probe-finder.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 3b9d0b8..1a35637 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1177,6 +1177,7 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
else {
/* Search upper class */
nscopes = dwarf_getscopes_die(sp_die, &scopes);
+ ret = -ENOENT;
while (nscopes-- > 1) {
pr_debug("Searching variables in %s\n",
dwarf_diename(&scopes[nscopes]));
@@ -1185,14 +1186,12 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
pf->pvar->var, 0,
&vr_die)) {
ret = convert_variable(&vr_die, pf);
- goto found;
+ break;
}
}
if (scopes)
free(scopes);
- ret = -ENOENT;
}
-found:
if (ret < 0)
pr_warning("Failed to find '%s' in this function.\n",
pf->pvar->var);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/