Skip to content

Commit

Permalink
perf header: Set nr_numa_nodes only when we parsed all the data
Browse files Browse the repository at this point in the history
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: Jiri Olsa <[email protected]>
Reported-by: Sukadev Bhattiprolu <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
olsajiri authored and acmel committed Oct 13, 2016
1 parent c611152 commit f957a53
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,6 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
if (ph->needs_swap)
nr = bswap_32(nr);

ph->env.nr_numa_nodes = nr;
nodes = zalloc(sizeof(*nodes) * nr);
if (!nodes)
return -ENOMEM;
Expand Down Expand Up @@ -1932,6 +1931,7 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse

free(str);
}
ph->env.nr_numa_nodes = nr;
ph->env.numa_nodes = nodes;
return 0;

Expand Down

0 comments on commit f957a53

Please sign in to comment.