diff options
author | Ian Rogers <irogers@google.com> | 2024-02-09 12:49:46 -0800 |
---|---|---|
committer | Sasha Levin <sashal@kernel.org> | 2024-03-26 18:18:34 -0400 |
commit | 1c3c67e7bce06bbf164ce8a7c3729d8cfb7c7f0f (patch) | |
tree | b546be81eb91a57bde59fb3dd244d9913f323965 /tools | |
parent | 9dddc3ca43b2397654505f4ca68e85064301f211 (diff) | |
download | linux-stable-1c3c67e7bce06bbf164ce8a7c3729d8cfb7c7f0f.tar.gz linux-stable-1c3c67e7bce06bbf164ce8a7c3729d8cfb7c7f0f.tar.bz2 linux-stable-1c3c67e7bce06bbf164ce8a7c3729d8cfb7c7f0f.zip |
perf stat: Avoid metric-only segv
[ Upstream commit 2543947c77e0e224bda86b4e7220c2f6714da463 ]
Cycles is recognized as part of a hard coded metric in stat-shadow.c,
it may call print_metric_only with a NULL fmt string leading to a
segfault. Handle the NULL fmt explicitly.
Fixes: 088519f318be ("perf stat: Move the display functions to stat-display.c")
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kaige Ye <ye@kaige.org>
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240209204947.3873294-4-irogers@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/stat-display.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index afe6db8e7bf4..969ce4009633 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -560,7 +560,7 @@ static void print_metric_only(struct perf_stat_config *config, if (color) mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1; - color_snprintf(str, sizeof(str), color ?: "", fmt, val); + color_snprintf(str, sizeof(str), color ?: "", fmt ?: "", val); fprintf(out, "%*s ", mlen, str); os->first = false; } |