linux/tools/perf/tests
Arnaldo Carvalho de Melo 8a45065958 perf machine: Propagate machine__init() error to callers
machine__init() always returns 0 even when memory allocation fails,
because commit 81f981d7ec ("perf machine: Free root_dir in
machine__init() error path") introduced 'int err = -ENOMEM' and an
error cleanup path but left the final 'return 0' instead of
'return err'.

Fix by returning err, check the return value in __machine__new_host()
which was ignoring it, and change machines__init() from void to int so
it too can propagate the error to perf_session__new(), aslr_tool__init()
and test callers.

The error cleanup also used zfree(&machine->kmaps), but kmaps is a
refcounted maps structure — use maps__zput() to properly drop the
reference, matching machine__exit().

Move dsos__init() and threads__init() before the first fallible
allocation (maps__new) so that machine__exit() is safe to call on
any machine struct that machine__init() touched, even on early failure.

Fixes: 81f981d7ec ("perf machine: Free root_dir in machine__init() error path")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-06-17 09:21:03 -03:00
..
config-fragments
shell perf test: Add inject ASLR test 2026-06-15 14:33:49 -03:00
workloads perf test: Compile named_threads workload with -O0 2026-06-11 21:14:30 -03:00
api-io.c
backward-ring-buffer.c
bitmap.c libperf cpumap: Make index and nr types unsigned 2026-04-01 14:50:53 -07:00
bp_account.c
bp_signal_overflow.c
bp_signal.c perf tools: Make more global variables static 2026-04-08 19:21:04 -07:00
Build perf tests: Add test for uncore event sorting 2026-05-20 18:23:55 -03:00
builtin-test.c perf test: Truncate printed test descriptions dynamically to avoid terminal wrapping 2026-06-11 12:05:26 -03:00
code-reading.c perf tools: Fix uninitialized pathname on uncompressed fallback in filename__decompress() 2026-06-10 18:56:01 -03:00
cpumap.c libperf cpumap: Make index and nr types unsigned 2026-04-01 14:50:53 -07:00
demangle-java-test.c
demangle-ocaml-test.c
demangle-rust-v0-test.c
dlfilter-test.c perf event: Fix size of synthesized sample with branch stacks 2026-05-20 16:11:30 -03:00
dso-data.c perf tools: Make more global variables static 2026-04-08 19:21:04 -07:00
dwarf-unwind.c perf machine: Explicitly pass in host perf_env 2025-07-25 10:37:57 -07:00
event_groups.c
event_update.c perf evlist: Improve default event for s390 2026-03-19 14:42:46 -07:00
event-times.c
evsel-roundtrip-name.c
evsel-tp-sched.c
expand-cgroup.c perf evlist: Improve default event for s390 2026-03-19 14:42:46 -07:00
expr.c
fdarray.c
genelf.c
hists_common.c
hists_common.h
hists_cumulate.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
hists_filter.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
hists_link.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
hists_output.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
hwmon_pmu.c perf tests hwmon_pmu: Use PRIu64 + (uint64_t) cast for a __u64 field to work more widely 2026-05-28 18:31:50 -03:00
is_printable_array.c
kallsyms-split.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
keep-tracking.c perf test: Switch cycles event to cpu-cycles 2025-10-15 23:59:12 +09:00
kmod-path.c
make perf data ctf: replace libbabeltrace with babeltrace2-ctf-writer 2026-06-04 17:34:52 -03:00
maps.c perf test maps: Additional maps__fixup_overlap_and_insert tests 2025-11-19 16:20:15 -08:00
mem.c
mem2node.c libperf cpumap: Make index and nr types unsigned 2026-04-01 14:50:53 -07:00
mmap-basic.c perf tests: Sort includes and add missed explicit dependencies 2026-05-27 08:20:31 -03:00
mmap-thread-lookup.c perf machine: Explicitly pass in host perf_env 2025-07-25 10:37:57 -07:00
openat-syscall-all-cpus.c libperf cpumap: Make index and nr types unsigned 2026-04-01 14:50:53 -07:00
openat-syscall-tp-fields.c perf evsel: Refactor evsel tracepoint sample accessors perf_sample 2026-05-20 16:35:59 -03:00
openat-syscall.c
parse-events.c perf test: Fix ratio_to_prev event parsing test 2026-04-02 12:51:10 -07:00
parse-metric.c perf test parse-metric: Ensure aggregate counts appear to have run 2026-02-08 11:30:01 -03:00
parse-no-sample-id-all.c perf session: Validate HEADER_ATTR attr.size before swapping 2026-05-29 11:44:32 -03:00
pe-file-parsing.c perf tools: Don't read build-ids from non-regular files 2025-11-26 10:13:38 -08:00
pe-file.c
pe-file.exe
pe-file.exe.debug
perf-hooks.c
perf-record.c perf sample: Make sure perf_sample__init/exit are used 2026-04-05 23:12:15 -07:00
perf-targz-src-pkg
perf-time-to-tsc.c perf test: Switch cycles event to cpu-cycles 2025-10-15 23:59:12 +09:00
pfm.c perf auxtrace: Remove errno.h from auxtrace.h and fix transitive dependencies 2025-11-13 23:03:11 -08:00
pmu-events.c perf test pmu-events: A sub-test per metric table 2026-06-04 11:36:36 -03:00
pmu.c perf arm-spe: Don't warn about the discard bit if it doesn't exist 2026-05-29 21:20:50 -03:00
sample-parsing.c perf event: Fix size of synthesized sample with branch stacks 2026-05-20 16:11:30 -03:00
sdt.c perf tools: Don't read build-ids from non-regular files 2025-11-26 10:13:38 -08:00
sigtrap.c
stat.c
subcmd-help.c perf test subcmd help: Add exclude disjoint subcmd names 2026-01-12 15:57:23 -03:00
sw-clock.c perf tests sw-clock: Mark the volatile tmp variable as __maybe_unused 2026-01-20 20:49:53 -03:00
switch-tracking.c perf evlist: Try to avoid computing evsel from sample 2026-05-20 16:39:40 -03:00
symbols.c perf symbol: Add setters for bitfields sharing a byte to avoid concurrent update issues 2026-06-03 16:53:45 -03:00
task-exit.c
tests-scripts.c perf test: Skip shebang and SPDX comments in shell test descriptions 2026-06-04 11:40:36 -03:00
tests-scripts.h
tests.h perf test: Add named_threads workload 2026-06-10 18:55:49 -03:00
thread-map.c perf tools: Use calloc() where applicable 2026-04-08 19:21:05 -07:00
thread-maps-share.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
time-utils-test.c
tool_pmu.c
topology.c perf tests topology: Switch env->arch use to env->e_machine 2026-06-03 16:45:04 -03:00
uncore-event-sorting.c perf tests: Add test for uncore event sorting 2026-05-20 18:23:55 -03:00
unit_number__scnprintf.c
util.c perf test: Split monolithic 'util' test suite into sub-tests 2026-06-04 11:40:51 -03:00
vmlinux-kallsyms.c perf machine: Propagate machine__init() error to callers 2026-06-17 09:21:03 -03:00
wp.c perf tools: Make more global variables static 2026-04-08 19:21:04 -07:00