Skip to content

Commit e000ea0

Browse files
JoseExpositoacmel
authored andcommitted
perf metricgroup: Fix use after free in metric__new()
We shouldn't free() something that will be used in the next line, fix it. Fixes: b85a4d6 ("perf metric: Allow modifiers on metrics") Addresses-Coverity-ID: 1494000 Signed-off-by: José Expósito <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 99fc11b commit e000ea0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/util/metricgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ static struct metric *metric__new(const struct pmu_event *pe,
209209
m->metric_name = pe->metric_name;
210210
m->modifier = modifier ? strdup(modifier) : NULL;
211211
if (modifier && !m->modifier) {
212-
free(m);
213212
expr__ctx_free(m->pctx);
213+
free(m);
214214
return NULL;
215215
}
216216
m->metric_expr = pe->metric_expr;

0 commit comments

Comments
 (0)