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 <jose.exposito89@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Garry <john.garry@huawei.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20211208171113.22089-1-jose.exposito89@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 99fc11b commit e000ea0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)