Skip to contentSkip to conversation

perf_counter tools: Initialize a stack variable before use

tip:perfcounters/core tip-bot for Arjan van de Ven 1 participant 1 message Jun 6, 2009 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  e9fbc9dc9214d6a9de7d62627be5414804fd7b9f
Gitweb:     http://git.kernel.org/tip/e9fbc9dc9214d6a9de7d62627be5414804fd7b9f
Author:     Arjan van de Ven <[email protected]>
AuthorDate: Sat, 6 Jun 2009 21:22:33 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 6 Jun 2009 21:22:33 +0200

perf_counter tools: Initialize a stack variable before use

the "perf report" utility crashed in some circumstances because the "sym" stack variable was not initialized before used (as also proven by valgrind).

With this fix both the crash goes away and valgrind no longer complains.

Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/util/symbol.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/symbol.c +2 -0
index 253821d..158588c 100644
@@ -457,6 +457,8 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
 
 	nr_syms = shdr.sh_size / shdr.sh_entsize;
 
+	memset(&sym, 0, sizeof(sym));
+
 	elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
 		struct symbol *f;
 		uint64_t obj_start;