[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aV2E7e2Cim8v8Bjm@x1>
Date: Tue, 6 Jan 2026 18:55:57 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>,
Faisal Bukhari <faisalbukhari523@...il.com>,
Ian Rogers <irogers@...gle.com>
Cc: James Clark <james.clark@...aro.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, thomas.falcon@...el.com,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf parse-events: Fix evsel allocation failure
On Mon, Sep 22, 2025 at 11:38:34PM +0530, Faisal Bukhari wrote:
> If evsel__new_idx() returns NULL, the function currently jumps
> to label 'out_err'.
> Here, references to `cpus` and `pmu_cpus` are dropped.
> Also, resources held by evsel->name and evsel->metric_id are freed.
> But if evsel__new_idx() returns NULL,
> it can lead to NULL pointer dereference.
You forgot to add:
Fixes: cd63c22168257a0b ("perf parse-events: Minor __add_event refactoring")
Reviewed-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Namhyung, I think this should go into v6.19-rc,
- Arnaldo
> Signed-off-by: Faisal Bukhari <faisalbukhari523@...il.com>
> ---
> tools/perf/util/parse-events.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 452f12191f6e..02e7ff94a2d2 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -286,8 +286,11 @@ __add_event(struct list_head *list, int *idx,
> event_attr_init(attr);
>
> evsel = evsel__new_idx(attr, *idx);
> - if (!evsel)
> - goto out_err;
> + if (!evsel) {
> + perf_cpu_map__put(cpus);
> + perf_cpu_map__put(pmu_cpus);
> + return NULL;
> + }
>
> if (name) {
> evsel->name = strdup(name);
> --
> 2.43.0
Powered by blists - more mailing lists