Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jiri Olsa <jolsa@kernel.org>
Reported-by: Sukadev 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
f957a530 c6111523

+1 -1
+1 -1
tools/perf/util/header.c
··· 1895 1895 if (ph->needs_swap) 1896 1896 nr = bswap_32(nr); 1897 1897 1898 - ph->env.nr_numa_nodes = nr; 1899 1898 nodes = zalloc(sizeof(*nodes) * nr); 1900 1899 if (!nodes) 1901 1900 return -ENOMEM; ··· 1931 1932 1932 1933 free(str); 1933 1934 } 1935 + ph->env.nr_numa_nodes = nr; 1934 1936 ph->env.numa_nodes = nodes; 1935 1937 return 0; 1936 1938