History

function-graph: Fix seqfile memory leak

Every time we cat set_graph_function, we leak memory allocated by seq_open().

Li Zefan committed 17 years ago

Commit 87827111 parent d8cc1ab1 file · +12 −3Browse files

Showing the changes to kernel/trace (1 of 1 file). Show all

Unified · Split

kernel/trace/ftrace.c+12−3
@@ -2595,6 +2595,14 @@ ftrace_graph_open(struct inode *inode, struct file *file) · 2594 unmodified lines
25952595 return ret;
25962596 }
25972597
2598+static int
2599+ftrace_graph_release(struct inode *inode, struct file *file)
2600+{
2601+ if (file->f_mode & FMODE_READ)
2602+ seq_release(inode, file);
2603+ return 0;
2604+}
2605+
25982606 static int
25992607 ftrace_set_func(unsigned long *array, int *idx, char *buffer)
26002608 {
@@ -2724,9 +2732,10 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, · 123 unmodified lines
27242732 }
27252733
27262734 static const struct file_operations ftrace_graph_fops = {
2727− .open = ftrace_graph_open,
2728− .read = seq_read,
2729− .write = ftrace_graph_write,
2735+ .open = ftrace_graph_open,
2736+ .read = seq_read,
2737+ .write = ftrace_graph_write,
2738+ .release = ftrace_graph_release,
27302739 };
27312740 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
27322741