]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
perf subcmd: avoid crash in exclude_cmds when excludes is empty
authorhupu <hupu.gm@gmail.com>
Wed, 10 Sep 2025 08:16:55 +0000 (16:16 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:23 +0000 (11:56 +0200)
commit24a08a87291e44cd8d893cc6f3d308cdacfa3fc2
treedfd2c6034a3ac40250faa1b29c71514b70a69078
parent9eb265e5aaa2fdb5ce37cad54febee5154579f28
perf subcmd: avoid crash in exclude_cmds when excludes is empty

[ Upstream commit a5edf3550f4260504b7e0ab3d40d13ffe924b773 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/subcmd/help.c