perf hists: hist_entry__cmp() may use he_tmp.hists, initialize it

This change “perf hists: hist_entry__cmp() may use he_tmp.hists, initialize it” in Linux kernel is authored by Arnaldo Carvalho de Melo <acme [at]> on Mon Aug 10 15:45:55 2015 -0300.

perf hists: hist_entry__cmp() may use he_tmp.hists, initialize it

The iter_add_next_cumulative_entry() function calls hist_entry__cmp(),
which may want to access the hists where this hist_entry is stored,
initialize it to let that happen and avoid segfaults.

Cc: Adrian Hunter <>
Cc: Borislav Petkov <>
Cc: David Ahern <>
Cc: Frederic Weisbecker <>
Cc: Jiri Olsa <>
Cc: Namhyung Kim <>
Cc: Stephane Eranian <>
Signed-off-by: Arnaldo Carvalho de Melo <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 5cef897.

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/perf/util/hist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index a6e9ddd..2fe6ea3 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -761,6 +761,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
 	struct hist_entry **he_cache = iter->priv;
 	struct hist_entry *he;
 	struct hist_entry he_tmp = {
+		.hists = evsel__hists(evsel),
 		.cpu = al->cpu,
 		.thread = al->thread,
 		.comm = thread__comm(al->thread),

The commit for this change in Linux stable tree is 5cef897 (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *