perf metricgroup: Fix metric expression copy leaks

metricgroup__copy_metric_events() allocates a new metric expression and
duplicates metric_name before linking the expression into the destination
metric event.

Free new_expr when strdup() fails, and free the duplicated metric_name on
the later error paths.

Fixes: b85a4d61d3 ("perf metric: Allow modifiers on metrics")
Signed-off-by: Yu Peng <pengyu@kylinos.cn>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Yu Peng 2026-06-02 16:11:04 +08:00 • committed by Namhyung Kim
commit ef3af1df4f