From: Jiri Olsa Date: Mon, 26 Jun 2023 20:16:05 +0000 (+0200) Subject: perf tools: Add missing else to cmd_daemon subcommand condition X-Git-Tag: v6.6.7~2391^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49a5e3edd35352833270dd18b0d5ca414fcc9406;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index f5674d8..83954af 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);