From: Arnaldo Carvalho de Melo Date: Fri, 10 Oct 2014 17:29:49 +0000 (-0300) Subject: perf evlist: Check that there is a thread_map when preparing a workload X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1aaf63b1ee912abd7675681f9d6ffaaf2ffc0451;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git perf evlist: Check that there is a thread_map when preparing a workload The perf_evlist__prepare_workload expects a thread map to be in place so that it can store the pid of the workload being started, so check it and tell the developer about it instead of segfaulting. Cc: Adrian Hunter Cc: Borislav Petkov Cc: David Ahern Cc: Don Zickus Cc: Frederic Weisbecker Cc: Jean Pihet Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-jvlz2f264e7kpmhjmwltikqw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 3cebc9a8d52e..5fc7bd42c803 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1276,8 +1276,14 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar sigaction(SIGUSR1, &act, NULL); } - if (target__none(target)) + if (target__none(target)) { + if (evlist->threads == NULL) { + fprintf(stderr, "FATAL: evlist->threads need to be set at this point (%s:%d).\n", + __func__, __LINE__); + goto out_close_pipes; + } evlist->threads->map[0] = evlist->workload.pid; + } close(child_ready_pipe[1]); close(go_pipe[0]);