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

perf help: Ensure clean_cmds is called on all paths

Avoid potential memory leaks.

Committer notes:

This is right before calling exit(1), so just to clean up memory leak
checker detection.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: André Almeida <andrealmeid@igalia.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230611233610.953456-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
0f0d1354 657a3efe

+3
+3
tools/perf/util/help-unknown-cmd.c
··· 92 92 93 93 main_cmds.names[0] = NULL; 94 94 clean_cmdnames(&main_cmds); 95 + clean_cmdnames(&other_cmds); 95 96 fprintf(stderr, "WARNING: You called a perf program named '%s', " 96 97 "which does not exist.\n" 97 98 "Continuing under the assumption that you meant '%s'\n", ··· 115 114 fprintf(stderr, "\t%s\n", main_cmds.names[i]->name); 116 115 } 117 116 end: 117 + clean_cmdnames(&main_cmds); 118 + clean_cmdnames(&other_cmds); 118 119 exit(1); 119 120 }