aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/symbol.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 86ec6c720f0f..f56158fb4dc9 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -921,6 +921,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)
921 GElf_Shdr shdr; 921 GElf_Shdr shdr;
922 Elf_Data *data; 922 Elf_Data *data;
923 Elf_Scn *sec; 923 Elf_Scn *sec;
924 Elf_Kind ek;
924 void *ptr; 925 void *ptr;
925 Elf *elf; 926 Elf *elf;
926 927
@@ -937,6 +938,10 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)
937 goto out_close; 938 goto out_close;
938 } 939 }
939 940
941 ek = elf_kind(elf);
942 if (ek != ELF_K_ELF)
943 goto out_elf_end;
944
940 if (gelf_getehdr(elf, &ehdr) == NULL) { 945 if (gelf_getehdr(elf, &ehdr) == NULL) {
941 pr_err("%s: cannot get elf header.\n", __func__); 946 pr_err("%s: cannot get elf header.\n", __func__);
942 goto out_elf_end; 947 goto out_elf_end;