Commit 22c36b18 authored by Wei Yang's avatar Wei Yang Committed by Steven Rostedt (VMware)

tracing: make tracing_init_dentry() returns an integer instead of a d_entry pointer

Current tracing_init_dentry() return a d_entry pointer, while is not
necessary. This function returns NULL on success or error on failure,
which means there is no valid d_entry pointer return.

Let's return 0 on success and negative value for error.

Link: https://lkml.kernel.org/r/20200712011036.70948-5-richard.weiyang@linux.alibaba.comSigned-off-by: default avatarWei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent dc300d77
...@@ -8971,21 +8971,21 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore) ...@@ -8971,21 +8971,21 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
* directory. It is called via fs_initcall() by any of the boot up code * directory. It is called via fs_initcall() by any of the boot up code
* and expects to return the dentry of the top level tracing directory. * and expects to return the dentry of the top level tracing directory.
*/ */
struct dentry *tracing_init_dentry(void) int tracing_init_dentry(void)
{ {
struct trace_array *tr = &global_trace; struct trace_array *tr = &global_trace;
if (security_locked_down(LOCKDOWN_TRACEFS)) { if (security_locked_down(LOCKDOWN_TRACEFS)) {
pr_warn("Tracing disabled due to lockdown\n"); pr_warn("Tracing disabled due to lockdown\n");
return ERR_PTR(-EPERM); return -EPERM;
} }
/* The top level trace array uses NULL as parent */ /* The top level trace array uses NULL as parent */
if (tr->dir) if (tr->dir)
return NULL; return 0;
if (WARN_ON(!tracefs_initialized())) if (WARN_ON(!tracefs_initialized()))
return ERR_PTR(-ENODEV); return -ENODEV;
/* /*
* As there may still be users that expect the tracing * As there may still be users that expect the tracing
...@@ -8996,7 +8996,7 @@ struct dentry *tracing_init_dentry(void) ...@@ -8996,7 +8996,7 @@ struct dentry *tracing_init_dentry(void)
tr->dir = debugfs_create_automount("tracing", NULL, tr->dir = debugfs_create_automount("tracing", NULL,
trace_automount, NULL); trace_automount, NULL);
return NULL; return 0;
} }
extern struct trace_eval_map *__start_ftrace_eval_maps[]; extern struct trace_eval_map *__start_ftrace_eval_maps[];
...@@ -9083,48 +9083,48 @@ static struct notifier_block trace_module_nb = { ...@@ -9083,48 +9083,48 @@ static struct notifier_block trace_module_nb = {
static __init int tracer_init_tracefs(void) static __init int tracer_init_tracefs(void)
{ {
struct dentry *d_tracer; int ret;
trace_access_lock_init(); trace_access_lock_init();
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
event_trace_init(); event_trace_init();
init_tracer_tracefs(&global_trace, d_tracer); init_tracer_tracefs(&global_trace, NULL);
ftrace_init_tracefs_toplevel(&global_trace, d_tracer); ftrace_init_tracefs_toplevel(&global_trace, NULL);
trace_create_file("tracing_thresh", 0644, d_tracer, trace_create_file("tracing_thresh", 0644, NULL,
&global_trace, &tracing_thresh_fops); &global_trace, &tracing_thresh_fops);
trace_create_file("README", 0444, d_tracer, trace_create_file("README", 0444, NULL,
NULL, &tracing_readme_fops); NULL, &tracing_readme_fops);
trace_create_file("saved_cmdlines", 0444, d_tracer, trace_create_file("saved_cmdlines", 0444, NULL,
NULL, &tracing_saved_cmdlines_fops); NULL, &tracing_saved_cmdlines_fops);
trace_create_file("saved_cmdlines_size", 0644, d_tracer, trace_create_file("saved_cmdlines_size", 0644, NULL,
NULL, &tracing_saved_cmdlines_size_fops); NULL, &tracing_saved_cmdlines_size_fops);
trace_create_file("saved_tgids", 0444, d_tracer, trace_create_file("saved_tgids", 0444, NULL,
NULL, &tracing_saved_tgids_fops); NULL, &tracing_saved_tgids_fops);
trace_eval_init(); trace_eval_init();
trace_create_eval_file(d_tracer); trace_create_eval_file(NULL);
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
register_module_notifier(&trace_module_nb); register_module_notifier(&trace_module_nb);
#endif #endif
#ifdef CONFIG_DYNAMIC_FTRACE #ifdef CONFIG_DYNAMIC_FTRACE
trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, trace_create_file("dyn_ftrace_total_info", 0444, NULL,
NULL, &tracing_dyn_info_fops); NULL, &tracing_dyn_info_fops);
#endif #endif
create_trace_instances(d_tracer); create_trace_instances(NULL);
update_tracer_options(&global_trace); update_tracer_options(&global_trace);
......
...@@ -737,7 +737,7 @@ struct dentry *trace_create_file(const char *name, ...@@ -737,7 +737,7 @@ struct dentry *trace_create_file(const char *name,
void *data, void *data,
const struct file_operations *fops); const struct file_operations *fops);
struct dentry *tracing_init_dentry(void); int tracing_init_dentry(void);
struct ring_buffer_event; struct ring_buffer_event;
......
...@@ -206,14 +206,14 @@ static const struct file_operations dynamic_events_ops = { ...@@ -206,14 +206,14 @@ static const struct file_operations dynamic_events_ops = {
/* Make a tracefs interface for controlling dynamic events */ /* Make a tracefs interface for controlling dynamic events */
static __init int init_dynamic_event(void) static __init int init_dynamic_event(void)
{ {
struct dentry *d_tracer;
struct dentry *entry; struct dentry *entry;
int ret;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
entry = tracefs_create_file("dynamic_events", 0644, d_tracer, entry = tracefs_create_file("dynamic_events", 0644, NULL,
NULL, &dynamic_events_ops); NULL, &dynamic_events_ops);
/* Event list interface */ /* Event list interface */
......
...@@ -1757,7 +1757,6 @@ static const struct file_operations synth_events_fops = { ...@@ -1757,7 +1757,6 @@ static const struct file_operations synth_events_fops = {
static __init int trace_events_synth_init(void) static __init int trace_events_synth_init(void)
{ {
struct dentry *entry = NULL; struct dentry *entry = NULL;
struct dentry *d_tracer;
int err = 0; int err = 0;
err = dyn_event_register(&synth_event_ops); err = dyn_event_register(&synth_event_ops);
...@@ -1766,13 +1765,11 @@ static __init int trace_events_synth_init(void) ...@@ -1766,13 +1765,11 @@ static __init int trace_events_synth_init(void)
return err; return err;
} }
d_tracer = tracing_init_dentry(); err = tracing_init_dentry();
if (IS_ERR(d_tracer)) { if (err)
err = PTR_ERR(d_tracer);
goto err; goto err;
}
entry = tracefs_create_file("synthetic_events", 0644, d_tracer, entry = tracefs_create_file("synthetic_events", 0644, NULL,
NULL, &synth_events_fops); NULL, &synth_events_fops);
if (!entry) { if (!entry) {
err = -ENODEV; err = -ENODEV;
......
...@@ -1336,13 +1336,13 @@ static const struct file_operations graph_depth_fops = { ...@@ -1336,13 +1336,13 @@ static const struct file_operations graph_depth_fops = {
static __init int init_graph_tracefs(void) static __init int init_graph_tracefs(void)
{ {
struct dentry *d_tracer; int ret;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
trace_create_file("max_graph_depth", 0644, d_tracer, trace_create_file("max_graph_depth", 0644, NULL,
NULL, &graph_depth_fops); NULL, &graph_depth_fops);
return 0; return 0;
......
...@@ -538,14 +538,14 @@ static const struct file_operations window_fops = { ...@@ -538,14 +538,14 @@ static const struct file_operations window_fops = {
*/ */
static int init_tracefs(void) static int init_tracefs(void)
{ {
struct dentry *d_tracer; int ret;
struct dentry *top_dir; struct dentry *top_dir;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return -ENOMEM; return -ENOMEM;
top_dir = tracefs_create_dir("hwlat_detector", d_tracer); top_dir = tracefs_create_dir("hwlat_detector", NULL);
if (!top_dir) if (!top_dir)
return -ENOMEM; return -ENOMEM;
......
...@@ -1901,14 +1901,14 @@ subsys_initcall(init_kprobe_trace_early); ...@@ -1901,14 +1901,14 @@ subsys_initcall(init_kprobe_trace_early);
/* Make a tracefs interface for controlling probe points */ /* Make a tracefs interface for controlling probe points */
static __init int init_kprobe_trace(void) static __init int init_kprobe_trace(void)
{ {
struct dentry *d_tracer; int ret;
struct dentry *entry; struct dentry *entry;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
entry = tracefs_create_file("kprobe_events", 0644, d_tracer, entry = tracefs_create_file("kprobe_events", 0644, NULL,
NULL, &kprobe_events_ops); NULL, &kprobe_events_ops);
/* Event list interface */ /* Event list interface */
...@@ -1916,7 +1916,7 @@ static __init int init_kprobe_trace(void) ...@@ -1916,7 +1916,7 @@ static __init int init_kprobe_trace(void)
pr_warn("Could not create tracefs 'kprobe_events' entry\n"); pr_warn("Could not create tracefs 'kprobe_events' entry\n");
/* Profile interface */ /* Profile interface */
entry = tracefs_create_file("kprobe_profile", 0444, d_tracer, entry = tracefs_create_file("kprobe_profile", 0444, NULL,
NULL, &kprobe_profile_ops); NULL, &kprobe_profile_ops);
if (!entry) if (!entry)
......
...@@ -367,13 +367,13 @@ static const struct file_operations ftrace_formats_fops = { ...@@ -367,13 +367,13 @@ static const struct file_operations ftrace_formats_fops = {
static __init int init_trace_printk_function_export(void) static __init int init_trace_printk_function_export(void)
{ {
struct dentry *d_tracer; int ret;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
trace_create_file("printk_formats", 0444, d_tracer, trace_create_file("printk_formats", 0444, NULL,
NULL, &ftrace_formats_fops); NULL, &ftrace_formats_fops);
return 0; return 0;
......
...@@ -554,20 +554,20 @@ __setup("stacktrace", enable_stacktrace); ...@@ -554,20 +554,20 @@ __setup("stacktrace", enable_stacktrace);
static __init int stack_trace_init(void) static __init int stack_trace_init(void)
{ {
struct dentry *d_tracer; int ret;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
trace_create_file("stack_max_size", 0644, d_tracer, trace_create_file("stack_max_size", 0644, NULL,
&stack_trace_max_size, &stack_max_size_fops); &stack_trace_max_size, &stack_max_size_fops);
trace_create_file("stack_trace", 0444, d_tracer, trace_create_file("stack_trace", 0444, NULL,
NULL, &stack_trace_fops); NULL, &stack_trace_fops);
#ifdef CONFIG_DYNAMIC_FTRACE #ifdef CONFIG_DYNAMIC_FTRACE
trace_create_file("stack_trace_filter", 0644, d_tracer, trace_create_file("stack_trace_filter", 0644, NULL,
&trace_ops, &stack_trace_filter_fops); &trace_ops, &stack_trace_filter_fops);
#endif #endif
......
...@@ -276,13 +276,13 @@ static const struct file_operations tracing_stat_fops = { ...@@ -276,13 +276,13 @@ static const struct file_operations tracing_stat_fops = {
static int tracing_stat_init(void) static int tracing_stat_init(void)
{ {
struct dentry *d_tracing; int ret;
d_tracing = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracing)) if (ret)
return -ENODEV; return -ENODEV;
stat_dir = tracefs_create_dir("trace_stat", d_tracing); stat_dir = tracefs_create_dir("trace_stat", NULL);
if (!stat_dir) { if (!stat_dir) {
pr_warn("Could not create tracefs 'trace_stat' entry\n"); pr_warn("Could not create tracefs 'trace_stat' entry\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -1625,21 +1625,20 @@ void destroy_local_trace_uprobe(struct trace_event_call *event_call) ...@@ -1625,21 +1625,20 @@ void destroy_local_trace_uprobe(struct trace_event_call *event_call)
/* Make a trace interface for controling probe points */ /* Make a trace interface for controling probe points */
static __init int init_uprobe_trace(void) static __init int init_uprobe_trace(void)
{ {
struct dentry *d_tracer;
int ret; int ret;
ret = dyn_event_register(&trace_uprobe_ops); ret = dyn_event_register(&trace_uprobe_ops);
if (ret) if (ret)
return ret; return ret;
d_tracer = tracing_init_dentry(); ret = tracing_init_dentry();
if (IS_ERR(d_tracer)) if (ret)
return 0; return 0;
trace_create_file("uprobe_events", 0644, d_tracer, trace_create_file("uprobe_events", 0644, NULL,
NULL, &uprobe_events_ops); NULL, &uprobe_events_ops);
/* Profile interface */ /* Profile interface */
trace_create_file("uprobe_profile", 0444, d_tracer, trace_create_file("uprobe_profile", 0444, NULL,
NULL, &uprobe_profile_ops); NULL, &uprobe_profile_ops);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment