function-graph: Fix seqfile memory leak
authorLi Zefan <lizf@cn.fujitsu.com>
Thu, 23 Jul 2009 03:29:11 +0000 (11:29 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 23 Jul 2009 13:53:23 +0000 (09:53 -0400)
Every time we cat set_graph_function, we leak memory allocated
by seq_open().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A67D907.2010500@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ftrace.c

index 4521c77d1a1aff64419d0afb0d6b84906c306454..1f3ec2afa511977b2882b5829105285762a50d45 100644 (file)
@@ -2595,6 +2595,14 @@ ftrace_graph_open(struct inode *inode, struct file *file)
        return ret;
 }
 
+static int
+ftrace_graph_release(struct inode *inode, struct file *file)
+{
+       if (file->f_mode & FMODE_READ)
+               seq_release(inode, file);
+       return 0;
+}
+
 static int
 ftrace_set_func(unsigned long *array, int *idx, char *buffer)
 {
@@ -2724,9 +2732,10 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
 }
 
 static const struct file_operations ftrace_graph_fops = {
-       .open = ftrace_graph_open,
-       .read = seq_read,
-       .write = ftrace_graph_write,
+       .open           = ftrace_graph_open,
+       .read           = seq_read,
+       .write          = ftrace_graph_write,
+       .release        = ftrace_graph_release,
 };
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */