All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: Vladislav Valtchev <vladislav.valtchev@gmail.com>,
	Yordan Karadzhov <y.karadz@gmail.com>
Subject: [PATCH 1/3] trace-cmd: Fix leaking of port_array memory
Date: Fri, 12 Jan 2018 13:08:48 -0500	[thread overview]
Message-ID: <20180112180930.345950960@goodmis.org> (raw)
In-Reply-To: 20180112180847.372748598@goodmis.org

[-- Attachment #1: 0001-trace-cmd-Fix-leaking-of-port_array-memory.patch --]
[-- Type: text/plain, Size: 786 bytes --]

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 --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;
 }
-- 
2.13.2

  reply	other threads:[~2018-01-12 18:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 18:08 [PATCH 0/3] trace-cmd: A few fixes Steven Rostedt
2018-01-12 18:08 ` Steven Rostedt [this message]
2018-01-12 18:08 ` [PATCH 2/3] trace-cmd msg: Set the min size of a message on init Steven Rostedt
2018-01-12 18:08 ` [PATCH 3/3] trace-cmd TAGS: Fix tags to not parse .pc directory of patch Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180112180930.345950960@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=vladislav.valtchev@gmail.com \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.