All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>,
	Faisal Bukhari <faisalbukhari523@gmail.com>,
	Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	thomas.falcon@intel.com, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf parse-events: Fix evsel allocation failure
Date: Tue, 6 Jan 2026 18:55:57 -0300	[thread overview]
Message-ID: <aV2E7e2Cim8v8Bjm@x1> (raw)
In-Reply-To: <20250922180834.1744399-1-faisalbukhari523@gmail.com>

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@redhat.com>

Namhyung, I think this should go into v6.19-rc,

- Arnaldo
 
> Signed-off-by: Faisal Bukhari <faisalbukhari523@gmail.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

  reply	other threads:[~2026-01-06 21:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-22 18:08 [PATCH] perf parse-events: Fix evsel allocation failure Faisal Bukhari
2026-01-06 21:55 ` Arnaldo Carvalho de Melo [this message]
2026-01-06 22:54   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aV2E7e2Cim8v8Bjm@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=faisalbukhari523@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=thomas.falcon@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.