Skip to contentSkip to conversation

Patch "perf tools: Fix leaking rec_argv in error cases" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Dec 6, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

perf tools: Fix leaking rec_argv in error cases

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
perf-tools-fix-leaking-rec_argv-in-error-cases.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Wed Dec 6 18:04:41 CET 2017

From: Martin Kepplinger <[email protected]>
Date: Wed, 13 Sep 2017 21:14:19 +0200
Subject: perf tools: Fix leaking rec_argv in error cases

From: Martin Kepplinger <[email protected]>

[ Upstream commit c896f85a7c15ab9d040ffac8b8003e47996602a2 ]

Let's free the allocated rec_argv in case we return early, in order to avoid leaking memory.

This adds free() at a few very similar places across the tree where it was missing.

---
 tools/perf/builtin-c2c.c       |    1 +
 tools/perf/builtin-mem.c       |    1 +
 tools/perf/builtin-timechart.c |    4 +++-
 tools/perf/builtin-trace.c     |    1 +
 4 files changed, 6 insertions(+), 1 deletion(-)
tools/perf/builtin-c2c.c +1 -0
@@ -2733,6 +2733,7 @@ static int perf_c2c__record(int argc, co
 		if (!perf_mem_events[j].supported) {
 			pr_err("failed: event '%s' not supported\n",
 			       perf_mem_events[j].name);
+			free(rec_argv);
 			return -1;
 		}
 
tools/perf/builtin-mem.c +1 -0
@@ -113,6 +113,7 @@ static int __cmd_record(int argc, const
 		if (!perf_mem_events[j].supported) {
 			pr_err("failed: event '%s' not supported\n",
 			       perf_mem_events__name(j));
+			free(rec_argv);
 			return -1;
 		}
 
tools/perf/builtin-timechart.c +3 -1
@@ -1732,8 +1732,10 @@ static int timechart__io_record(int argc
 	if (rec_argv == NULL)
 		return -ENOMEM;
 
-	if (asprintf(&filter, "common_pid != %d", getpid()) < 0)
+	if (asprintf(&filter, "common_pid != %d", getpid()) < 0) {
+		free(rec_argv);
 		return -ENOMEM;
+	}
 
 	p = rec_argv;
 	for (i = 0; i < common_args_nr; i++)
tools/perf/builtin-trace.c +1 -0
@@ -2086,6 +2086,7 @@ static int trace__record(struct trace *t
 			rec_argv[j++] = "syscalls:sys_enter,syscalls:sys_exit";
 		else {
 			pr_err("Neither raw_syscalls nor syscalls events exist.\n");
+			free(rec_argv);
 			return -1;
 		}
 	}

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/perf-tools-fix-leaking-rec_argv-in-error-cases.patch