Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf hist: Add missing map__put() in error case

We need to map__put() before returning from failure of
sample__resolve_callchain().

Detected with gcc's ASan.

Signed-off-by: Changbin Du <changbin.du@gmail.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Krister Johansen <kjlx@templeofstupid.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Fixes: 9c68ae98c6f7 ("perf callchain: Reference count maps")
Link: http://lkml.kernel.org/r/20190316080556.3075-10-changbin.du@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Changbin Du and committed by
Arnaldo Carvalho de Melo
cb6186ae 70c819e4

+3 -1
+3 -1
tools/perf/util/hist.c
··· 1111 1111 1112 1112 err = sample__resolve_callchain(iter->sample, &callchain_cursor, &iter->parent, 1113 1113 iter->evsel, al, max_stack_depth); 1114 - if (err) 1114 + if (err) { 1115 + map__put(alm); 1115 1116 return err; 1117 + } 1116 1118 1117 1119 err = iter->ops->prepare_entry(iter, al); 1118 1120 if (err)