public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	James Clark <james.clark@linaro.org>,
	Howard Chu <howardchu95@gmail.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] perf evsel: Ensure the fallback message is always written to
Date: Fri, 19 Sep 2025 16:54:46 -0300	[thread overview]
Message-ID: <aM21BtgwBRBWrEEs@x1> (raw)
In-Reply-To: <20250918172416.1247940-1-irogers@google.com>

On Thu, Sep 18, 2025 at 10:24:15AM -0700, Ian Rogers wrote:
> The fallback message is unconditionally printed in places like
> record__open. If no fallback is attempted this can lead to printing
> uninitialized data, crashes, etc.
> 
> Fixes: c0a54341c0e8 ("perf evsel: Introduce event fallback method")
> Signed-off-by: Ian Rogers <irogers@google.com>

Thanks, applied to perf-tools-next,

- Arnaldo

> ---
>  tools/perf/util/evsel.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 477cddf08c5c..814ef6f6b32a 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -3565,7 +3565,7 @@ bool evsel__fallback(struct evsel *evsel, struct target *target, int err,
>  
>  		/* If event has exclude user then don't exclude kernel. */
>  		if (evsel->core.attr.exclude_user)
> -			return false;
> +			goto no_fallback;
>  
>  		/* Is there already the separator in the name. */
>  		if (strchr(name, '/') ||
> @@ -3573,7 +3573,7 @@ bool evsel__fallback(struct evsel *evsel, struct target *target, int err,
>  			sep = "";
>  
>  		if (asprintf(&new_name, "%s%su", name, sep) < 0)
> -			return false;
> +			goto no_fallback;
>  
>  		free(evsel->name);
>  		evsel->name = new_name;
> @@ -3596,17 +3596,19 @@ bool evsel__fallback(struct evsel *evsel, struct target *target, int err,
>  			sep = "";
>  
>  		if (asprintf(&new_name, "%s%sH", name, sep) < 0)
> -			return false;
> +			goto no_fallback;
>  
>  		free(evsel->name);
>  		evsel->name = new_name;
>  		/* Apple M1 requires exclude_guest */
> -		scnprintf(msg, msgsize, "trying to fall back to excluding guest samples");
> +		scnprintf(msg, msgsize, "Trying to fall back to excluding guest samples");
>  		evsel->core.attr.exclude_guest = 1;
>  
>  		return true;
>  	}
> -
> +no_fallback:
> +	scnprintf(msg, msgsize, "No fallback found for '%s' for error %d",
> +		  evsel__name(evsel), err);
>  	return false;
>  }
>  
> -- 
> 2.51.0.470.ga7dc726c21-goog

      parent reply	other threads:[~2025-09-19 19:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 17:24 [PATCH v1 1/2] perf evsel: Ensure the fallback message is always written to Ian Rogers
2025-09-18 17:24 ` [PATCH v1 2/2] perf build-id: Ensure snprintf string is empty when size is 0 Ian Rogers
2025-09-19 19:54 ` Arnaldo Carvalho de Melo [this message]

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=aM21BtgwBRBWrEEs@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=howardchu95@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox