perf util: Fix use after free in metric__new
PATCH v3 1/1 perf util: Fix use after free in metric__new
Fix a use after free on the error branch accessing the "metric" struct.
Fixes b85a4d61d302 (perf metric: Allow modifiers on metrics)
Addresses-Coverity-ID: 1494000
Acked-by Ian Rogers <[email protected]>
Reviewed-by John Garry <[email protected]>
Signed-off-by José Expósito <[email protected]>
---
v2: Add Fixes and Acked-by tags (thanks to Ian Rogers)
v3: Add Reviewed-by tag (thanks to John Garry)
Improve patch description
--- tools/perf/util/metricgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/metricgroup.c +1 -1
@@ -209,8 +209,8 @@ static struct metric *metric__new(const struct pmu_event *pe, m->metric_name = pe->metric_name; m->modifier = modifier ?strdup (modifier) :NULL ;if (modifier && !m->modifier) { -free (m);expr__ctx_free (m->pctx); +free (m);return NULL ; } m->metric_expr = pe->metric_expr;
Signature · 1 line
2.25.1