diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-03-11 03:43:13 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 12:06:02 -0400 |
commit | 85397956de304106e2fdace2db8f69ab4e966bc5 (patch) | |
tree | b7cd69a5931554edb6567054a5f335be75efbd79 /tools | |
parent | 334fe7a3c63624eb1bba42f81eb088d5665d9f3e (diff) |
perf evlist: Use cpu_map__nr() helper
Use the cpu_map__nr() helper to protect a possible NULL cpu map
dereference.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1362987798-24969-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/evlist.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index a199f1887bef..a482547495b6 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -228,7 +228,7 @@ void perf_evlist__disable(struct perf_evlist *evlist) | |||
228 | int cpu, thread; | 228 | int cpu, thread; |
229 | struct perf_evsel *pos; | 229 | struct perf_evsel *pos; |
230 | 230 | ||
231 | for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { | 231 | for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) { |
232 | list_for_each_entry(pos, &evlist->entries, node) { | 232 | list_for_each_entry(pos, &evlist->entries, node) { |
233 | if (!perf_evsel__is_group_leader(pos)) | 233 | if (!perf_evsel__is_group_leader(pos)) |
234 | continue; | 234 | continue; |
@@ -443,7 +443,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m | |||
443 | struct perf_evsel *evsel; | 443 | struct perf_evsel *evsel; |
444 | int cpu, thread; | 444 | int cpu, thread; |
445 | 445 | ||
446 | for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { | 446 | for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) { |
447 | int output = -1; | 447 | int output = -1; |
448 | 448 | ||
449 | for (thread = 0; thread < evlist->threads->nr; thread++) { | 449 | for (thread = 0; thread < evlist->threads->nr; thread++) { |
@@ -470,7 +470,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m | |||
470 | return 0; | 470 | return 0; |
471 | 471 | ||
472 | out_unmap: | 472 | out_unmap: |
473 | for (cpu = 0; cpu < evlist->cpus->nr; cpu++) { | 473 | for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) { |
474 | if (evlist->mmap[cpu].base != NULL) { | 474 | if (evlist->mmap[cpu].base != NULL) { |
475 | munmap(evlist->mmap[cpu].base, evlist->mmap_len); | 475 | munmap(evlist->mmap[cpu].base, evlist->mmap_len); |
476 | evlist->mmap[cpu].base = NULL; | 476 | evlist->mmap[cpu].base = NULL; |
@@ -725,7 +725,7 @@ int perf_evlist__open(struct perf_evlist *evlist) | |||
725 | 725 | ||
726 | return 0; | 726 | return 0; |
727 | out_err: | 727 | out_err: |
728 | ncpus = evlist->cpus ? evlist->cpus->nr : 1; | 728 | ncpus = cpu_map__nr(evlist->cpus); |
729 | nthreads = evlist->threads ? evlist->threads->nr : 1; | 729 | nthreads = evlist->threads ? evlist->threads->nr : 1; |
730 | 730 | ||
731 | list_for_each_entry_reverse(evsel, &evlist->entries, node) | 731 | list_for_each_entry_reverse(evsel, &evlist->entries, node) |