diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-04-08 12:27:48 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-08-26 10:58:30 -0400 |
commit | 3b4acbb92dbda4829e021e5c6d5410658849fa1c (patch) | |
tree | 22e536fc37323733041f88628eb878922098538c /tools/perf/ui | |
parent | 3dab6ac080dcd7f71cb9ceb84ad7dafecd6f7c07 (diff) |
perf script: Fix memory leaks in list_scripts()
In case memory resources for *buf* and *paths* were allocated, jump to
*out* and release them before return.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Addresses-Coverity-ID: 1444328 ("Resource leak")
Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
Link: http://lkml.kernel.org/r/20190408162748.GA21008@embeddedor
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r-- | tools/perf/ui/browsers/scripts.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index f2fd9f0d7ab5..50e0c03171f2 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c | |||
@@ -133,8 +133,10 @@ static int list_scripts(char *script_name, bool *custom, | |||
133 | int key = ui_browser__input_window("perf script command", | 133 | int key = ui_browser__input_window("perf script command", |
134 | "Enter perf script command line (without perf script prefix)", | 134 | "Enter perf script command line (without perf script prefix)", |
135 | script_args, "", 0); | 135 | script_args, "", 0); |
136 | if (key != K_ENTER) | 136 | if (key != K_ENTER) { |
137 | return -1; | 137 | ret = -1; |
138 | goto out; | ||
139 | } | ||
138 | sprintf(script_name, "%s script %s", perf, script_args); | 140 | sprintf(script_name, "%s script %s", perf, script_args); |
139 | } else if (choice < num + max_std) { | 141 | } else if (choice < num + max_std) { |
140 | strcpy(script_name, paths[choice]); | 142 | strcpy(script_name, paths[choice]); |