Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

hupu and committed by
Namhyung Kim
a5edf355 ca81e74d

+3
+3
tools/lib/subcmd/help.c
··· 75 75 size_t ci, cj, ei; 76 76 int cmp; 77 77 78 + if (!excludes->cnt) 79 + return; 80 + 78 81 ci = cj = ei = 0; 79 82 while (ci < cmds->cnt && ei < excludes->cnt) { 80 83 cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);