dect
/
linux-2.6
Archived
13
0
Fork 0

perf probe: Fix a memory leak for scopes array

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

Reviewed-by: Pekka Enberg <penberg@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20110811110229.19900.63019.stgit@fedora15
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Masami Hiramatsu 2011-08-11 20:02:29 +09:00 committed by Arnaldo Carvalho de Melo
parent e9b52ef222
commit 8afa2a707d
1 changed files with 2 additions and 3 deletions

View File

@ -660,6 +660,7 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
else { else {
/* Search upper class */ /* Search upper class */
nscopes = dwarf_getscopes_die(sp_die, &scopes); nscopes = dwarf_getscopes_die(sp_die, &scopes);
ret = -ENOENT;
while (nscopes-- > 1) { while (nscopes-- > 1) {
pr_debug("Searching variables in %s\n", pr_debug("Searching variables in %s\n",
dwarf_diename(&scopes[nscopes])); dwarf_diename(&scopes[nscopes]));
@ -668,14 +669,12 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
pf->pvar->var, 0, pf->pvar->var, 0,
&vr_die)) { &vr_die)) {
ret = convert_variable(&vr_die, pf); ret = convert_variable(&vr_die, pf);
goto found; break;
} }
} }
if (scopes) if (scopes)
free(scopes); free(scopes);
ret = -ENOENT;
} }
found:
if (ret < 0) if (ret < 0)
pr_warning("Failed to find '%s' in this function.\n", pr_warning("Failed to find '%s' in this function.\n",
pf->pvar->var); pf->pvar->var);