From 49a5e3edd35352833270dd18b0d5ca414fcc9406 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 26 Jun 2023 22:16:05 +0200 Subject: perf tools: Add missing else to cmd_daemon subcommand condition Namhyung reported segfault in perf daemon start command. It's caused by extra check on argv[0] which is set to NULL by previous __cmd_start call. Adding missing else to skip the extra check. Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf") Reported-and-Tested-by: Namhyung Kim Reported-by: Thomas Richter Signed-off-by: Jiri Olsa Cc: Mark Rutland Cc: Peter Zijlstra Cc: Ian Rogers Cc: Adrian Hunter Cc: Arnaldo Carvalho de Melo Cc: Ingo Molnar Cc: Alexander Shishkin Link: https://lore.kernel.org/r/20230626201606.2514679-1-jolsa@kernel.org Signed-off-by: Namhyung Kim --- tools/perf/builtin-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/perf') diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index f5674d824a40..83954af36753 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -1524,7 +1524,7 @@ int cmd_daemon(int argc, const char **argv) if (argc) { if (!strcmp(argv[0], "start")) ret = __cmd_start(&__daemon, daemon_options, argc, argv); - if (!strcmp(argv[0], "signal")) + else if (!strcmp(argv[0], "signal")) ret = __cmd_signal(&__daemon, daemon_options, argc, argv); else if (!strcmp(argv[0], "stop")) ret = __cmd_stop(&__daemon, daemon_options, argc, argv); -- cgit v1.2.3