diff mbox series

[1/3] trace-cmd: Fix leaking of port_array memory

Message ID 20180112180930.345950960@goodmis.org (mailing list archive)
State Superseded, archived
Headers show
Series trace-cmd: A few fixes | expand

Commit Message

Steven Rostedt Jan. 12, 2018, 6:08 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The port_array is allocated in create_all_readers() to send the ports that
are created to the client. But after it is sent, it is no longer needed, but
it was not freed. This causes a memory leak.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 trace-listen.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/trace-listen.c b/trace-listen.c
index 38de59263800..871df0e7a04c 100644
--- a/trace-listen.c
+++ b/trace-listen.c
@@ -587,9 +587,11 @@  static int *create_all_readers(const char *node, const char *port,
 		write(msg_handle->fd, "\0", 1);
 	}
 
+	free(port_array);
 	return pid_array;
 
  out_free:
+	free(port_array);
 	destroy_all_readers(cpus, pid_array, node, port);
 	return NULL;
 }