diff options
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/ftrace.c | 44 | ||||
-rw-r--r-- | kernel/trace/trace.c | 30 |
2 files changed, 16 insertions, 58 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 0fa92f677c92..cf81f27ce6c6 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -2469,57 +2469,35 @@ static int | |||
2469 | ftrace_avail_open(struct inode *inode, struct file *file) | 2469 | ftrace_avail_open(struct inode *inode, struct file *file) |
2470 | { | 2470 | { |
2471 | struct ftrace_iterator *iter; | 2471 | struct ftrace_iterator *iter; |
2472 | int ret; | ||
2473 | 2472 | ||
2474 | if (unlikely(ftrace_disabled)) | 2473 | if (unlikely(ftrace_disabled)) |
2475 | return -ENODEV; | 2474 | return -ENODEV; |
2476 | 2475 | ||
2477 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); | 2476 | iter = __seq_open_private(file, &show_ftrace_seq_ops, sizeof(*iter)); |
2478 | if (!iter) | 2477 | if (iter) { |
2479 | return -ENOMEM; | 2478 | iter->pg = ftrace_pages_start; |
2480 | 2479 | iter->ops = &global_ops; | |
2481 | iter->pg = ftrace_pages_start; | ||
2482 | iter->ops = &global_ops; | ||
2483 | |||
2484 | ret = seq_open(file, &show_ftrace_seq_ops); | ||
2485 | if (!ret) { | ||
2486 | struct seq_file *m = file->private_data; | ||
2487 | |||
2488 | m->private = iter; | ||
2489 | } else { | ||
2490 | kfree(iter); | ||
2491 | } | 2480 | } |
2492 | 2481 | ||
2493 | return ret; | 2482 | return iter ? 0 : -ENOMEM; |
2494 | } | 2483 | } |
2495 | 2484 | ||
2496 | static int | 2485 | static int |
2497 | ftrace_enabled_open(struct inode *inode, struct file *file) | 2486 | ftrace_enabled_open(struct inode *inode, struct file *file) |
2498 | { | 2487 | { |
2499 | struct ftrace_iterator *iter; | 2488 | struct ftrace_iterator *iter; |
2500 | int ret; | ||
2501 | 2489 | ||
2502 | if (unlikely(ftrace_disabled)) | 2490 | if (unlikely(ftrace_disabled)) |
2503 | return -ENODEV; | 2491 | return -ENODEV; |
2504 | 2492 | ||
2505 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); | 2493 | iter = __seq_open_private(file, &show_ftrace_seq_ops, sizeof(*iter)); |
2506 | if (!iter) | 2494 | if (iter) { |
2507 | return -ENOMEM; | 2495 | iter->pg = ftrace_pages_start; |
2508 | 2496 | iter->flags = FTRACE_ITER_ENABLED; | |
2509 | iter->pg = ftrace_pages_start; | 2497 | iter->ops = &global_ops; |
2510 | iter->flags = FTRACE_ITER_ENABLED; | ||
2511 | iter->ops = &global_ops; | ||
2512 | |||
2513 | ret = seq_open(file, &show_ftrace_seq_ops); | ||
2514 | if (!ret) { | ||
2515 | struct seq_file *m = file->private_data; | ||
2516 | |||
2517 | m->private = iter; | ||
2518 | } else { | ||
2519 | kfree(iter); | ||
2520 | } | 2498 | } |
2521 | 2499 | ||
2522 | return ret; | 2500 | return iter ? 0 : -ENOMEM; |
2523 | } | 2501 | } |
2524 | 2502 | ||
2525 | static void ftrace_filter_reset(struct ftrace_hash *hash) | 2503 | static void ftrace_filter_reset(struct ftrace_hash *hash) |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index f11a285ee5bb..4fb10ef727d3 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2413,15 +2413,13 @@ static struct trace_iterator * | |||
2413 | __tracing_open(struct inode *inode, struct file *file) | 2413 | __tracing_open(struct inode *inode, struct file *file) |
2414 | { | 2414 | { |
2415 | long cpu_file = (long) inode->i_private; | 2415 | long cpu_file = (long) inode->i_private; |
2416 | void *fail_ret = ERR_PTR(-ENOMEM); | ||
2417 | struct trace_iterator *iter; | 2416 | struct trace_iterator *iter; |
2418 | struct seq_file *m; | 2417 | int cpu; |
2419 | int cpu, ret; | ||
2420 | 2418 | ||
2421 | if (tracing_disabled) | 2419 | if (tracing_disabled) |
2422 | return ERR_PTR(-ENODEV); | 2420 | return ERR_PTR(-ENODEV); |
2423 | 2421 | ||
2424 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); | 2422 | iter = __seq_open_private(file, &tracer_seq_ops, sizeof(*iter)); |
2425 | if (!iter) | 2423 | if (!iter) |
2426 | return ERR_PTR(-ENOMEM); | 2424 | return ERR_PTR(-ENOMEM); |
2427 | 2425 | ||
@@ -2478,32 +2476,15 @@ __tracing_open(struct inode *inode, struct file *file) | |||
2478 | tracing_iter_reset(iter, cpu); | 2476 | tracing_iter_reset(iter, cpu); |
2479 | } | 2477 | } |
2480 | 2478 | ||
2481 | ret = seq_open(file, &tracer_seq_ops); | ||
2482 | if (ret < 0) { | ||
2483 | fail_ret = ERR_PTR(ret); | ||
2484 | goto fail_buffer; | ||
2485 | } | ||
2486 | |||
2487 | m = file->private_data; | ||
2488 | m->private = iter; | ||
2489 | |||
2490 | mutex_unlock(&trace_types_lock); | 2479 | mutex_unlock(&trace_types_lock); |
2491 | 2480 | ||
2492 | return iter; | 2481 | return iter; |
2493 | 2482 | ||
2494 | fail_buffer: | ||
2495 | for_each_tracing_cpu(cpu) { | ||
2496 | if (iter->buffer_iter[cpu]) | ||
2497 | ring_buffer_read_finish(iter->buffer_iter[cpu]); | ||
2498 | } | ||
2499 | free_cpumask_var(iter->started); | ||
2500 | tracing_start(); | ||
2501 | fail: | 2483 | fail: |
2502 | mutex_unlock(&trace_types_lock); | 2484 | mutex_unlock(&trace_types_lock); |
2503 | kfree(iter->trace); | 2485 | kfree(iter->trace); |
2504 | kfree(iter); | 2486 | seq_release_private(inode, file); |
2505 | 2487 | return ERR_PTR(-ENOMEM); | |
2506 | return fail_ret; | ||
2507 | } | 2488 | } |
2508 | 2489 | ||
2509 | int tracing_open_generic(struct inode *inode, struct file *filp) | 2490 | int tracing_open_generic(struct inode *inode, struct file *filp) |
@@ -2539,11 +2520,10 @@ static int tracing_release(struct inode *inode, struct file *file) | |||
2539 | tracing_start(); | 2520 | tracing_start(); |
2540 | mutex_unlock(&trace_types_lock); | 2521 | mutex_unlock(&trace_types_lock); |
2541 | 2522 | ||
2542 | seq_release(inode, file); | ||
2543 | mutex_destroy(&iter->mutex); | 2523 | mutex_destroy(&iter->mutex); |
2544 | free_cpumask_var(iter->started); | 2524 | free_cpumask_var(iter->started); |
2545 | kfree(iter->trace); | 2525 | kfree(iter->trace); |
2546 | kfree(iter); | 2526 | seq_release_private(inode, file); |
2547 | return 0; | 2527 | return 0; |
2548 | } | 2528 | } |
2549 | 2529 | ||