From: Ian Rogers Date: Fri, 5 May 2023 20:41:19 +0000 (-0700) Subject: perf metrics: Fix SEGV with --for-each-cgroup X-Git-Tag: Ubuntu-6.5.0-9.9~2701^2~2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=6c73f819b6b6d6f052e8dbe3f66f0693554ddf48;p=mirror_ubuntu-kernels.git perf metrics: Fix SEGV with --for-each-cgroup Ensure the metric threshold is copied correctly or else a use of uninitialized memory happens. Fixes: d0a3052f6faefffc ("perf metric: Compute and print threshold values") Reported-by: Namhyung Kim Signed-off-by: Ian Rogers Tested-by: Namhyung Kim Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kajol Jain Cc: Mark Rutland Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20230505204119.3443491-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 4b9a16291b96..c566c6859302 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -1730,6 +1730,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, return -ENOMEM; new_expr->metric_expr = old_expr->metric_expr; + new_expr->metric_threshold = old_expr->metric_threshold; new_expr->metric_name = strdup(old_expr->metric_name); if (!new_expr->metric_name) return -ENOMEM;