linux/tools/lib/subcmd
hupu a5edf3550f perf subcmd: avoid crash in exclude_cmds when excludes is empty
When cross-compiling the perf tool for ARM64, `perf help` may crash
with the following assertion failure:

  help.c:122: exclude_cmds: Assertion `cmds->names[ci] == NULL' failed.

This happens when the perf binary is not named exactly "perf" or when
multiple "perf-*" binaries exist in the same directory. In such cases,
the `excludes` command list can be empty, which leads to the final
assertion in exclude_cmds() being triggered.

Add a simple guard at the beginning of exclude_cmds() to return early
if excludes->cnt is zero, preventing the crash.

Signed-off-by: hupu <hupu.gm@gmail.com>
Reported-by: Guilherme Amadio <amadio@gentoo.org>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20250909094953.106706-1-amadio@gentoo.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2025-09-12 17:51:35 -07:00
..
Build
Makefile tools: Drop nonsensical -O6 2024-09-11 13:08:36 -03:00
exec-cmd.c libsubcmd: Avoid two path statics, removing 8192 bytes from .bss 2023-05-28 10:25:55 -03:00
exec-cmd.h
help.c perf subcmd: avoid crash in exclude_cmds when excludes is empty 2025-09-12 17:51:35 -07:00
help.h
pager.c
pager.h
parse-options.c libsubcmd: Silence compiler warning 2024-10-23 14:38:34 -07:00
parse-options.h tools/lib/subcmd: Replace NORETURN usage with __noreturn 2023-05-16 06:31:54 -07:00
run-command.c tools subcmd: Tighten the filename size in check_if_command_finished 2025-07-22 18:17:53 -07:00
run-command.h tools subcmd: Add check_if_command_finished() 2024-04-08 17:43:20 -03:00
sigchain.c
sigchain.h
subcmd-config.c
subcmd-config.h
subcmd-util.h libsubcmd: Move va_end() before exit 2024-11-13 16:27:35 -03:00