提交 44d041b7 编写于 作者: H He Zhe 提交者: Arnaldo Carvalho de Melo

libperf: Add NULL pointer check for cpu_map iteration and NULL assignment for all_cpus.

A NULL pointer may be passed to perf_cpu_map__cpu and then cause a
crash, such as the one commit cb71f7d4 ("libperf: Setup initial
evlist::all_cpus value") fix.
Signed-off-by: NHe Zhe <zhe.he@windriver.com>
Acked-by: NJiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kyle Meyer <meyerk@hpe.com>
Link: http://lore.kernel.org/lkml/1583665157-349023-1-git-send-email-zhe.he@windriver.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 23cbb41c
......@@ -247,7 +247,7 @@ struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx)
{
if (idx < cpus->nr)
if (cpus && idx < cpus->nr)
return cpus->map[idx];
return -1;
......
......@@ -125,6 +125,7 @@ void perf_evlist__exit(struct perf_evlist *evlist)
perf_cpu_map__put(evlist->cpus);
perf_thread_map__put(evlist->threads);
evlist->cpus = NULL;
evlist->all_cpus = NULL;
evlist->threads = NULL;
fdarray__exit(&evlist->pollfd);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册