aboutsummaryrefslogtreecommitdiffstats
path: root/trace-listen.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2016-09-12 14:15:44 -0400
committerSteven Rostedt <rostedt@goodmis.org>2016-10-30 19:46:49 -0400
commitb72211fb30f605f7cc54ee066953fca8a4d7463e (patch)
tree746f044cdd7d356a3318334c2f86b4713ac293da /trace-listen.c
parent9eddb072da11f13c693de2963bdb2fb9606bb521 (diff)
downloadtrace-cmd-b72211fb30f605f7cc54ee066953fca8a4d7463e.tar.gz
trace-cmd listen: Free temp files in put_together_file()
The temp files used in put_together_file() are only used within that function. They need to be freed before leaving that function. Funny enough, they are freed on failure. Since the same allocations must be freed on failure as on success, have them use the same return path. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'trace-listen.c')
-rw-r--r--trace-listen.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/trace-listen.c b/trace-listen.c
index 71244cb4..ee8639fc 100644
--- a/trace-listen.c
+++ b/trace-listen.c
@@ -617,6 +617,7 @@ static int put_together_file(int cpus, int ofd, const char *node,
{
char **temp_files;
int cpu;
+ int ret = -ENOMEM;
/* Now put together the file */
temp_files = malloc(sizeof(*temp_files) * cpus);
@@ -626,19 +627,17 @@ static int put_together_file(int cpus, int ofd, const char *node,
for (cpu = 0; cpu < cpus; cpu++) {
temp_files[cpu] = get_temp_file(node, port, cpu);
if (!temp_files[cpu])
- goto fail;
+ goto out;
}
tracecmd_attach_cpu_data_fd(ofd, cpus, temp_files);
- free(temp_files);
- return 0;
-
- fail:
+ ret = 0;
+ out:
for (cpu--; cpu >= 0; cpu--) {
put_temp_file(temp_files[cpu]);
}
free(temp_files);
- return -ENOMEM;
+ return ret;
}
static int process_client(const char *node, const char *port, int fd)