[PATCH] trace: fix memory leak in create_filter()

From: Takeshi Misawa
Date: Fri Nov 02 2018 - 22:24:43 EST


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@xxxxxxxxx>
---
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