aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Olsa <[email protected]>2014-03-02 14:32:07 +0100
committerArnaldo Carvalho de Melo <[email protected]>2014-03-10 11:17:14 -0300
commit155b3a13a65d4217316dbe094843f2a7df0711fa (patch)
tree50220eab009a1088fcc8b9de51dfb69e9845c536
parent02c5bb4a352a4cca56e9b5d3a2a57d61062eb2e1 (diff)
perf symbols: Fix crash in elf_section_by_name
Fixing crash in elf_section_by_name function caused by missing section name in elf binary. Reported-by: Albert Strasheim <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Cc: Albert Strasheim <[email protected]> Cc: Corey Ashford <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/perf/util/symbol-elf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 3e9f336740fa..516d19fb999b 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -151,15 +151,15 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
gelf_getshdr(sec, shp);
str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name);
- if (!strcmp(name, str)) {
+ if (str && !strcmp(name, str)) {
if (idx)
*idx = cnt;
- break;
+ return sec;
}
++cnt;
}
- return sec;
+ return NULL;
}
#define elf_section__for_each_rel(reldata, pos, pos_mem, idx, nr_entries) \