Skip to content

Commit d122ed6

Browse files
Takeshi Misawarostedt
authored andcommitted
tracing: Fix memory leak in tracing_err_log_open()
When tracing_err_log_open() calls seq_open(), allocated memory is not freed. kmemleak report: unreferenced object 0xffff92c0781d1100 (size 128): comm "tail", pid 15116, jiffies 4295163855 (age 22.704s) hex dump (first 32 bytes): 00 f0 08 e5 c0 92 ff ff 00 10 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<000000000d0687d5>] kmem_cache_alloc+0x11f/0x1e0 [<000000003e3039a8>] seq_open+0x2f/0x90 [<000000008dd36b7d>] tracing_err_log_open+0x67/0x140 [<000000005a431ae2>] do_dentry_open+0x1df/0x3a0 [<00000000a2910603>] vfs_open+0x2f/0x40 [<0000000038b0a383>] path_openat+0x2e8/0x1690 [<00000000fe025bda>] do_filp_open+0x9b/0x110 [<00000000483a5091>] do_sys_open+0x1ba/0x260 [<00000000c558b5fd>] __x64_sys_openat+0x20/0x30 [<000000006881ec07>] do_syscall_64+0x5a/0x130 [<00000000571c2e94>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fix this by calling seq_release() in tracing_err_log_fops.release(). Link: http://lkml.kernel.org/r/20190628105640.GA1863@DESKTOP Fixes: 8a06290 ("tracing: Add tracing error log") Reviewed-by: Tom Zanussi <[email protected]> Signed-off-by: Takeshi Misawa <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 3961126 commit d122ed6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

kernel/trace/trace.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7126,12 +7126,24 @@ static ssize_t tracing_err_log_write(struct file *file,
71267126
return count;
71277127
}
71287128

7129+
static int tracing_err_log_release(struct inode *inode, struct file *file)
7130+
{
7131+
struct trace_array *tr = inode->i_private;
7132+
7133+
trace_array_put(tr);
7134+
7135+
if (file->f_mode & FMODE_READ)
7136+
seq_release(inode, file);
7137+
7138+
return 0;
7139+
}
7140+
71297141
static const struct file_operations tracing_err_log_fops = {
71307142
.open = tracing_err_log_open,
71317143
.write = tracing_err_log_write,
71327144
.read = seq_read,
71337145
.llseek = seq_lseek,
7134-
.release = tracing_release_generic_tr,
7146+
.release = tracing_err_log_release,
71357147
};
71367148

71377149
static int tracing_buffers_open(struct inode *inode, struct file *filp)

0 commit comments

Comments
 (0)