[PATCH v4 3/9] perf disasm: Fix potential NULL pointer dereference in arch__find()
From: Ian Rogers
Date: Thu Jul 09 2026 - 22:50:19 EST
If arch_new_fn[e_machine]() fails (e.g., returning NULL to reject an
architecture or upon allocation failure), the error path attempts to
print result->name, dereferencing a NULL pointer and leading to a
segmentation fault. Fix it by printing the numeric e_machine value
instead.
Reported-by: sashiko-bot <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/linux-perf-users/20260709035721.9EE901F000E9@xxxxxxxxxxxxxxx/
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/disasm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index 0a1a7e9cf3ef..5b114f089d56 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -182,8 +182,8 @@ const struct arch *arch__find(uint16_t e_machine, uint32_t e_flags, const char *
result = arch_new_fn[e_machine](&key, cpuid);
if (!result) {
- pr_err("%s: failed to initialize %s (%u) arch priv area\n",
- __func__, result->name, e_machine);
+ pr_err("%s: failed to initialize %u arch priv area\n",
+ __func__, e_machine);
free(tmp);
return NULL;
}
--
2.55.0.795.g602f6c329a-goog