Messages in this thread Patch in this message | | | From | Ilkka Koskinen <> | Subject | [PATCH] perf data convert: Fix segfault when converting to json on arm64 | Date | Thu, 11 Jan 2024 15:29:23 -0800 |
| |
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 <ilkka@os.amperecomputing.com> --- tools/perf/util/data-convert-json.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c index 5bb3c2ba95ca..5d6de1cef546 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -97,6 +97,11 @@ static void output_json_format(FILE *out, bool comma, int depth, const char *for static void output_json_key_string(FILE *out, bool comma, int depth, const char *key, const char *value) { + if (!value) { + pr_info("No value set for key %s\n", key); + return; + } + output_json_delimiters(out, comma, depth); output_json_string(out, key); fputs(": ", out); -- 2.43.0
| |