The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Takeshi Misawa <jeliantsurux@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] trace: fix memory leak in create_filter()
Date: Sat, 3 Nov 2018 11:25:46 +0900	[thread overview]
Message-ID: <20181103022546.GA1404@jeantsuru-pc> (raw)

In create_filter(), pe variable is leaked.

Since commit 80765597bc58 ("tracing: Rewrite filter logic to be simpler
and faster"), create_filter_finish() is missing.

kmemleak:

unreferenced object 0xffff90148ba9c790 (size 8):
  comm "bash", pid 1378, jiffies 4294731025 (age 15.258s)
  hex dump (first 8 bytes):
    00 00 00 00 00 00 00 00                          ........
  backtrace:
    [<00000000d9a25450>] create_filter+0x47/0xc0
    [<0000000084514f08>] set_trigger_filter+0x87/0x130
    [<0000000017f6c9ef>] event_trigger_callback+0x114/0x220
    [<000000005096f447>] event_trigger_write+0x113/0x1b0
    [<00000000a5f767d1>] __vfs_write+0x36/0x1a0
    [<00000000ca62b71e>] vfs_write+0xa5/0x1a0
    [<00000000fdbd8005>] ksys_write+0x4f/0xb0
    [<00000000ec6e3711>] do_syscall_64+0x5b/0x160
    [<000000003ad36bb4>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [<000000007a35f0f5>] 0xffffffffffffffff

Fix this.

Signed-off-by: Takeshi Misawa <jeliantsurux@gmail.com>
---
I found kmemleak in tracing subsystem.
Please consider this patch.

Regards.
---
 kernel/trace/trace_events_filter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 84a65173b1e9..fb4ba08163ba 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1719,6 +1719,8 @@ static int create_filter(struct trace_event_call *call,
 	if (err && set_str)
 		append_filter_err(pe, *filterp);
 
+	create_filter_finish(pe);
+
 	return err;
 }
 
-- 
2.19.1


                 reply	other threads:[~2018-11-03  2:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20181103022546.GA1404@jeantsuru-pc \
    --to=jeliantsurux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox