Commit f957a530 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf header: Set nr_numa_nodes only when we parsed all the data

Sukadev reported segfault on releasing perf env's numa data.  It's due
to nr_numa_nodes being set no matter if the numa data gets parsed
properly. The perf_env__exit crash the on releasing non existed data.

Setting nr_numa_nodes only when data are parsed out properly.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Reported-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-dt9c0zgkt4hybn2cr4xiawta@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c6111523
...@@ -1895,7 +1895,6 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse ...@@ -1895,7 +1895,6 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
if (ph->needs_swap) if (ph->needs_swap)
nr = bswap_32(nr); nr = bswap_32(nr);
ph->env.nr_numa_nodes = nr;
nodes = zalloc(sizeof(*nodes) * nr); nodes = zalloc(sizeof(*nodes) * nr);
if (!nodes) if (!nodes)
return -ENOMEM; return -ENOMEM;
...@@ -1932,6 +1931,7 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse ...@@ -1932,6 +1931,7 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
free(str); free(str);
} }
ph->env.nr_numa_nodes = nr;
ph->env.numa_nodes = nodes; ph->env.numa_nodes = nodes;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment