diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-05-29 06:52:32 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-04 08:48:03 -0400 |
commit | 0c188a07b6a399e3df66534c29fef0a2082aaf57 (patch) | |
tree | 92bff0e3cf97bc39d62909786d692a40941aea91 /tools | |
parent | b69cf53640da2b86439596118cfa95233154ee76 (diff) |
perf probe: Fix a segfault if asked for variable it doesn't find
Fix a segfault bug by asking for variable it doesn't find.
Since the convert_variable() didn't handle error code returned
from convert_variable_location(), it just passed an incomplete
variable field and then a segfault was occurred when formatting
the field.
This fixes that bug by handling success code correctly in
convert_variable(). Other callers of convert_variable_location()
are correctly checking the return code.
This bug was introduced by following commit. But another hidden
erroneous error handling has been there previously (-ENOMEM case).
commit 3d918a12a1b3088ac16ff37fa52760639d6e2403
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20140529105232.28251.30447.stgit@ltc230.yrl.intra.hitachi.co.jp
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/probe-finder.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 562762117639..9d8eb26f0533 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -511,12 +511,12 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf) | |||
511 | 511 | ||
512 | ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops, | 512 | ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops, |
513 | &pf->sp_die, pf->tvar); | 513 | &pf->sp_die, pf->tvar); |
514 | if (ret == -ENOENT) | 514 | if (ret == -ENOENT || ret == -EINVAL) |
515 | pr_err("Failed to find the location of %s at this address.\n" | 515 | pr_err("Failed to find the location of %s at this address.\n" |
516 | " Perhaps, it has been optimized out.\n", pf->pvar->var); | 516 | " Perhaps, it has been optimized out.\n", pf->pvar->var); |
517 | else if (ret == -ENOTSUP) | 517 | else if (ret == -ENOTSUP) |
518 | pr_err("Sorry, we don't support this variable location yet.\n"); | 518 | pr_err("Sorry, we don't support this variable location yet.\n"); |
519 | else if (pf->pvar->field) { | 519 | else if (ret == 0 && pf->pvar->field) { |
520 | ret = convert_variable_fields(vr_die, pf->pvar->var, | 520 | ret = convert_variable_fields(vr_die, pf->pvar->var, |
521 | pf->pvar->field, &pf->tvar->ref, | 521 | pf->pvar->field, &pf->tvar->ref, |
522 | &die_mem); | 522 | &die_mem); |