From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
James Clark <james.clark@linaro.org>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH v7 2/9] perf config: Make perf_etc_perfconfig() never return NULL
Date: Thu, 1 Oct 2026 20:53:53 +0200 [thread overview]
Message-ID: <20261001185400.2754753-3-acme@kernel.org> (raw)
In-Reply-To: <20261001185400.2754753-1-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
perf_etc_perfconfig() returns what system_path() gives, and that
allocates, so on failure every caller dereferenced NULL, the
pre-existing ones in perf_config_set__init() and in the daemon
included. For the usual absolute ETC_PERFCONFIG system_path() just
returns a strdup of it, so use ETC_PERFCONFIG itself when that fails.
Assisted-by: LLM
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/config.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 85e50d0a25580da0..6e0ff8a9140ccf96 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -571,8 +571,14 @@ static int perf_config_from_file(config_fn_t fn, const char *filename, void *dat
const char *perf_etc_perfconfig(void)
{
static const char *system_wide;
+
if (!system_wide)
- system_wide = system_path(ETC_PERFCONFIG);
+ /*
+ * ETC_PERFCONFIG is absolute, so its unresolved path is
+ * the same string, better than the callers crashing.
+ */
+ system_wide = system_path(ETC_PERFCONFIG) ?: ETC_PERFCONFIG;
+
return system_wide;
}
--
2.55.0
next prev parent reply other threads:[~2026-10-01 18:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 18:53 [PATCH v7 0/9] perf tools: Add progress diagnostics and a false-sharing workload Arnaldo Carvalho de Melo
2026-10-01 18:53 ` [PATCH v7 1/9] perf config: Move perf_config__set_variable() to util/config.c Arnaldo Carvalho de Melo
2026-10-01 18:53 ` Arnaldo Carvalho de Melo [this message]
2026-10-01 18:53 ` [PATCH v7 3/9] perf mutex: Add DEFINE_MUTEX() static initializer Arnaldo Carvalho de Melo
2026-10-01 18:53 ` [PATCH v7 4/9] perf mutex: Add DO_ONCE() for one-time initialization Arnaldo Carvalho de Melo
2026-10-01 18:53 ` [PATCH v7 5/9] perf config: Serialize config file access with a mutex Arnaldo Carvalho de Melo
2026-10-01 18:53 ` [PATCH v7 6/9] perf report: Add --progress option Arnaldo Carvalho de Melo
2026-10-01 18:53 ` [PATCH v7 7/9] perf report: Add --no-progress option Arnaldo Carvalho de Melo
2026-10-01 18:53 ` [PATCH v7 8/9] perf scripts: Add perf-stuck, to tell where a running perf is stuck Arnaldo Carvalho de Melo
2026-10-01 18:54 ` [PATCH v7 9/9] perf test: Add false_sharing workload exhibiting cross-CPU false sharing Arnaldo Carvalho de Melo
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=20261001185400.2754753-3-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.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=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®