Skip to content

Commit bae4d1f

Browse files
ilkka-koskinennamhyung
authored andcommitted
perf data convert: Fix segfault when converting to json when cpu_desc isn't set
Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't get assigned. Running $ perf data convert --to-json perf.data.json ends up calling output_json_string() with NULL pointer, which causes a segmentation fault. Signed-off-by: Ilkka Koskinen <[email protected]> Acked-by: Arnaldo Carvalho de Melo <[email protected]> Cc: James Clark <[email protected]> Cc: Evgeny Pistun <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 529d581 commit bae4d1f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/util/data-convert-json.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ static void output_headers(struct perf_session *session, struct convert_json *c)
284284
output_json_key_string(out, true, 2, "os-release", header->env.os_release);
285285
output_json_key_string(out, true, 2, "arch", header->env.arch);
286286

287-
output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc);
287+
if (header->env.cpu_desc)
288+
output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc);
289+
288290
output_json_key_string(out, true, 2, "cpuid", header->env.cpuid);
289291
output_json_key_format(out, true, 2, "nrcpus-online", "%u", header->env.nr_cpus_online);
290292
output_json_key_format(out, true, 2, "nrcpus-avail", "%u", header->env.nr_cpus_avail);

0 commit comments

Comments
 (0)