diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-07-30 19:46:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-07-30 19:46:58 -0400 |
commit | b592972493c38665efd7d429a01b23fcb21e331a (patch) | |
tree | de212f5ffaa6b1a11c17fe5780f931dedd0c865f /kernel | |
parent | ec6a8679fa8ce977c8b7f86238455b494699de74 (diff) | |
parent | 636eacee3b0c76915151db37203cc624becb6d7b (diff) |
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
tracing/stat: Fix seqfile memory leak
function-graph: Fix seqfile memory leak
trace_stack: Fix seqfile memory leak
profile: Suppress warning about large allocations when profile=1 is specified
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/ftrace.c | 15 | ||||
-rw-r--r-- | kernel/trace/trace_stack.c | 7 | ||||
-rw-r--r-- | kernel/trace/trace_stat.c | 34 |
3 files changed, 36 insertions, 20 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4521c77d1a1a..1f3ec2afa511 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -2596,6 +2596,14 @@ ftrace_graph_open(struct inode *inode, struct file *file) | |||
2596 | } | 2596 | } |
2597 | 2597 | ||
2598 | static int | 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 | |||
2606 | static int | ||
2599 | ftrace_set_func(unsigned long *array, int *idx, char *buffer) | 2607 | ftrace_set_func(unsigned long *array, int *idx, char *buffer) |
2600 | { | 2608 | { |
2601 | struct dyn_ftrace *rec; | 2609 | struct dyn_ftrace *rec; |
@@ -2724,9 +2732,10 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, | |||
2724 | } | 2732 | } |
2725 | 2733 | ||
2726 | static const struct file_operations ftrace_graph_fops = { | 2734 | static const struct file_operations ftrace_graph_fops = { |
2727 | .open = ftrace_graph_open, | 2735 | .open = ftrace_graph_open, |
2728 | .read = seq_read, | 2736 | .read = seq_read, |
2729 | .write = ftrace_graph_write, | 2737 | .write = ftrace_graph_write, |
2738 | .release = ftrace_graph_release, | ||
2730 | }; | 2739 | }; |
2731 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | 2740 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
2732 | 2741 | ||
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index e644af910124..6a2a9d484cd6 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c | |||
@@ -301,17 +301,14 @@ static const struct seq_operations stack_trace_seq_ops = { | |||
301 | 301 | ||
302 | static int stack_trace_open(struct inode *inode, struct file *file) | 302 | static int stack_trace_open(struct inode *inode, struct file *file) |
303 | { | 303 | { |
304 | int ret; | 304 | return seq_open(file, &stack_trace_seq_ops); |
305 | |||
306 | ret = seq_open(file, &stack_trace_seq_ops); | ||
307 | |||
308 | return ret; | ||
309 | } | 305 | } |
310 | 306 | ||
311 | static const struct file_operations stack_trace_fops = { | 307 | static const struct file_operations stack_trace_fops = { |
312 | .open = stack_trace_open, | 308 | .open = stack_trace_open, |
313 | .read = seq_read, | 309 | .read = seq_read, |
314 | .llseek = seq_lseek, | 310 | .llseek = seq_lseek, |
311 | .release = seq_release, | ||
315 | }; | 312 | }; |
316 | 313 | ||
317 | int | 314 | int |
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c index e66f5e493342..aea321c82fa0 100644 --- a/kernel/trace/trace_stat.c +++ b/kernel/trace/trace_stat.c | |||
@@ -73,7 +73,7 @@ static struct rb_node *release_next(struct rb_node *node) | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | static void reset_stat_session(struct stat_session *session) | 76 | static void __reset_stat_session(struct stat_session *session) |
77 | { | 77 | { |
78 | struct rb_node *node = session->stat_root.rb_node; | 78 | struct rb_node *node = session->stat_root.rb_node; |
79 | 79 | ||
@@ -83,10 +83,17 @@ static void reset_stat_session(struct stat_session *session) | |||
83 | session->stat_root = RB_ROOT; | 83 | session->stat_root = RB_ROOT; |
84 | } | 84 | } |
85 | 85 | ||
86 | static void reset_stat_session(struct stat_session *session) | ||
87 | { | ||
88 | mutex_lock(&session->stat_mutex); | ||
89 | __reset_stat_session(session); | ||
90 | mutex_unlock(&session->stat_mutex); | ||
91 | } | ||
92 | |||
86 | static void destroy_session(struct stat_session *session) | 93 | static void destroy_session(struct stat_session *session) |
87 | { | 94 | { |
88 | debugfs_remove(session->file); | 95 | debugfs_remove(session->file); |
89 | reset_stat_session(session); | 96 | __reset_stat_session(session); |
90 | mutex_destroy(&session->stat_mutex); | 97 | mutex_destroy(&session->stat_mutex); |
91 | kfree(session); | 98 | kfree(session); |
92 | } | 99 | } |
@@ -150,7 +157,7 @@ static int stat_seq_init(struct stat_session *session) | |||
150 | int i; | 157 | int i; |
151 | 158 | ||
152 | mutex_lock(&session->stat_mutex); | 159 | mutex_lock(&session->stat_mutex); |
153 | reset_stat_session(session); | 160 | __reset_stat_session(session); |
154 | 161 | ||
155 | if (!ts->stat_cmp) | 162 | if (!ts->stat_cmp) |
156 | ts->stat_cmp = dummy_cmp; | 163 | ts->stat_cmp = dummy_cmp; |
@@ -183,7 +190,7 @@ exit: | |||
183 | return ret; | 190 | return ret; |
184 | 191 | ||
185 | exit_free_rbtree: | 192 | exit_free_rbtree: |
186 | reset_stat_session(session); | 193 | __reset_stat_session(session); |
187 | mutex_unlock(&session->stat_mutex); | 194 | mutex_unlock(&session->stat_mutex); |
188 | return ret; | 195 | return ret; |
189 | } | 196 | } |
@@ -250,16 +257,21 @@ static const struct seq_operations trace_stat_seq_ops = { | |||
250 | static int tracing_stat_open(struct inode *inode, struct file *file) | 257 | static int tracing_stat_open(struct inode *inode, struct file *file) |
251 | { | 258 | { |
252 | int ret; | 259 | int ret; |
253 | 260 | struct seq_file *m; | |
254 | struct stat_session *session = inode->i_private; | 261 | struct stat_session *session = inode->i_private; |
255 | 262 | ||
263 | ret = stat_seq_init(session); | ||
264 | if (ret) | ||
265 | return ret; | ||
266 | |||
256 | ret = seq_open(file, &trace_stat_seq_ops); | 267 | ret = seq_open(file, &trace_stat_seq_ops); |
257 | if (!ret) { | 268 | if (ret) { |
258 | struct seq_file *m = file->private_data; | 269 | reset_stat_session(session); |
259 | m->private = session; | 270 | return ret; |
260 | ret = stat_seq_init(session); | ||
261 | } | 271 | } |
262 | 272 | ||
273 | m = file->private_data; | ||
274 | m->private = session; | ||
263 | return ret; | 275 | return ret; |
264 | } | 276 | } |
265 | 277 | ||
@@ -270,11 +282,9 @@ static int tracing_stat_release(struct inode *i, struct file *f) | |||
270 | { | 282 | { |
271 | struct stat_session *session = i->i_private; | 283 | struct stat_session *session = i->i_private; |
272 | 284 | ||
273 | mutex_lock(&session->stat_mutex); | ||
274 | reset_stat_session(session); | 285 | reset_stat_session(session); |
275 | mutex_unlock(&session->stat_mutex); | ||
276 | 286 | ||
277 | return 0; | 287 | return seq_release(i, f); |
278 | } | 288 | } |
279 | 289 | ||
280 | static const struct file_operations tracing_stat_fops = { | 290 | static const struct file_operations tracing_stat_fops = { |