linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf script: Fix memory leaks in list_scripts()
@ 2019-04-08 16:27 Gustavo A. R. Silva
  2019-04-22 15:14 ` Gustavo A. R. Silva
       [not found] ` <156689437793.24518.1210962260082729908.tip-bot2@tip-bot2>
  0 siblings, 2 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-04-08 16:27 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen
  Cc: linux-kernel, Gustavo A. R. Silva

In case memory resources for *buf* and *paths* were allocated,
jump to *out* and release them before return.

Addresses-Coverity-ID: 1444328 ("Resource leak")
Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 tools/perf/ui/browsers/scripts.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index 27cf3ab88d13..f4edb18f67ec 100644
--- a/tools/perf/ui/browsers/scripts.c
+++ b/tools/perf/ui/browsers/scripts.c
@@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
 		int key = ui_browser__input_window("perf script command",
 				"Enter perf script command line (without perf script prefix)",
 				script_args, "", 0);
-		if (key != K_ENTER)
-			return -1;
+		if (key != K_ENTER) {
+			ret = -1;
+			goto out;
+		}
 		sprintf(script_name, "%s script %s", perf, script_args);
 	} else if (choice < num + max_std) {
 		strcpy(script_name, paths[choice]);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-08-27 21:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 16:27 [PATCH] perf script: Fix memory leaks in list_scripts() Gustavo A. R. Silva
2019-04-22 15:14 ` Gustavo A. R. Silva
2019-08-26  4:06   ` Gustavo A. R. Silva
2019-08-26 14:07     ` Arnaldo Carvalho de Melo
2019-08-26 15:59       ` Gustavo A. R. Silva
     [not found] ` <156689437793.24518.1210962260082729908.tip-bot2@tip-bot2>
2019-08-27 16:12   ` [tip: perf/core] " Gustavo A. R. Silva
2019-08-27 21:45     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).