Skip to content

Commit c10ea84

Browse files
GustavoARSilvagregkh
authored andcommitted
perf script: Fix memory leaks in list_scripts()
[ Upstream commit 3b4acbb ] 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: 6f3da20 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8d70572 commit c10ea84

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎tools/perf/ui/browsers/scripts.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
131131
int key = ui_browser__input_window("perf script command",
132132
"Enter perf script command line (without perf script prefix)",
133133
script_args, "", 0);
134-
if (key != K_ENTER)
135-
return -1;
134+
if (key != K_ENTER) {
135+
ret = -1;
136+
goto out;
137+
}
136138
sprintf(script_name, "%s script %s", perf, script_args);
137139
} else if (choice < num + max_std) {
138140
strcpy(script_name, paths[choice]);

0 commit comments

Comments
 (0)