linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] perf util: Fix use after free in metric__new
@ 2021-12-12 11:58 José Expósito
  2021-12-13  8:47 ` John Garry
  0 siblings, 1 reply; 2+ messages in thread
From: José Expósito @ 2021-12-12 11:58 UTC (permalink / raw)
  To: peterz
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, ak, john.garry, linux-perf-users, linux-kernel,
	José Expósito

Fixes: b85a4d61d302 (perf metric: Allow modifiers on metrics)
Addresses-Coverity-ID: 1494000
Acked-by: Ian Rogers <irogers@google.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>

---

v2: Add Fixes and Acked-by tags
---
 tools/perf/util/metricgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index fffe02aae3ed..4d2fed3aefd1 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] perf util: Fix use after free in metric__new
  2021-12-12 11:58 [PATCH v2] perf util: Fix use after free in metric__new José Expósito
@ 2021-12-13  8:47 ` John Garry
  0 siblings, 0 replies; 2+ messages in thread
From: John Garry @ 2021-12-13  8:47 UTC (permalink / raw)
  To: José Expósito, peterz
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
	irogers, ak, linux-perf-users, linux-kernel

On 12/12/2021 11:58, José Expósito wrote:
> Fixes: b85a4d61d302 (perf metric: Allow modifiers on metrics)
> Addresses-Coverity-ID: 1494000
> Acked-by: Ian Rogers <irogers@google.com>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>

Reviewed-by: John Garry <john.garry@huawei.com>

> 
> ---
> 
> v2: Add Fixes and Acked-by tags
> ---
>   tools/perf/util/metricgroup.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index fffe02aae3ed..4d2fed3aefd1 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -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;
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-13  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 11:58 [PATCH v2] perf util: Fix use after free in metric__new José Expósito
2021-12-13  8:47 ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).