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

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.com



Signed-off-by: default avatarWei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent dc300d77
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -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
 * 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;

	if (security_locked_down(LOCKDOWN_TRACEFS)) {
		pr_warn("Tracing disabled due to lockdown\n");
		return ERR_PTR(-EPERM);
		return -EPERM;
	}

	/* The top level trace array uses  NULL as parent */
	if (tr->dir)
		return NULL;
		return 0;

	if (WARN_ON(!tracefs_initialized()))
		return ERR_PTR(-ENODEV);
		return -ENODEV;

	/*
	 * As there may still be users that expect the tracing
@@ -8996,7 +8996,7 @@ struct dentry *tracing_init_dentry(void)
	tr->dir = debugfs_create_automount("tracing", NULL,
					   trace_automount, NULL);

	return NULL;
	return 0;
}

extern struct trace_eval_map *__start_ftrace_eval_maps[];
@@ -9083,48 +9083,48 @@ static struct notifier_block trace_module_nb = {

static __init int tracer_init_tracefs(void)
{
	struct dentry *d_tracer;
	int ret;

	trace_access_lock_init();

	d_tracer = tracing_init_dentry();
	if (IS_ERR(d_tracer))
	ret = tracing_init_dentry();
	if (ret)
		return 0;

	event_trace_init();

	init_tracer_tracefs(&global_trace, d_tracer);
	ftrace_init_tracefs_toplevel(&global_trace, d_tracer);
	init_tracer_tracefs(&global_trace, NULL);
	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);

	trace_create_file("README", 0444, d_tracer,
	trace_create_file("README", 0444, NULL,
			NULL, &tracing_readme_fops);

	trace_create_file("saved_cmdlines", 0444, d_tracer,
	trace_create_file("saved_cmdlines", 0444, NULL,
			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);

	trace_create_file("saved_tgids", 0444, d_tracer,
	trace_create_file("saved_tgids", 0444, NULL,
			NULL, &tracing_saved_tgids_fops);

	trace_eval_init();

	trace_create_eval_file(d_tracer);
	trace_create_eval_file(NULL);

#ifdef CONFIG_MODULES
	register_module_notifier(&trace_module_nb);
#endif

#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);
#endif

	create_trace_instances(d_tracer);
	create_trace_instances(NULL);

	update_tracer_options(&global_trace);

+1 −1
Original line number Diff line number Diff line
@@ -737,7 +737,7 @@ struct dentry *trace_create_file(const char *name,
				 void *data,
				 const struct file_operations *fops);

struct dentry *tracing_init_dentry(void);
int tracing_init_dentry(void);

struct ring_buffer_event;

+4 −4
Original line number Diff line number Diff line
@@ -206,14 +206,14 @@ static const struct file_operations dynamic_events_ops = {
/* Make a tracefs interface for controlling dynamic events */
static __init int init_dynamic_event(void)
{
	struct dentry *d_tracer;
	struct dentry *entry;
	int ret;

	d_tracer = tracing_init_dentry();
	if (IS_ERR(d_tracer))
	ret = tracing_init_dentry();
	if (ret)
		return 0;

	entry = tracefs_create_file("dynamic_events", 0644, d_tracer,
	entry = tracefs_create_file("dynamic_events", 0644, NULL,
				    NULL, &dynamic_events_ops);

	/* Event list interface */
+3 −6
Original line number Diff line number Diff line
@@ -1757,7 +1757,6 @@ static const struct file_operations synth_events_fops = {
static __init int trace_events_synth_init(void)
{
	struct dentry *entry = NULL;
	struct dentry *d_tracer;
	int err = 0;

	err = dyn_event_register(&synth_event_ops);
@@ -1766,13 +1765,11 @@ static __init int trace_events_synth_init(void)
		return err;
	}

	d_tracer = tracing_init_dentry();
	if (IS_ERR(d_tracer)) {
		err = PTR_ERR(d_tracer);
	err = tracing_init_dentry();
	if (err)
		goto err;
	}

	entry = tracefs_create_file("synthetic_events", 0644, d_tracer,
	entry = tracefs_create_file("synthetic_events", 0644, NULL,
				    NULL, &synth_events_fops);
	if (!entry) {
		err = -ENODEV;
+4 −4
Original line number Diff line number Diff line
@@ -1336,13 +1336,13 @@ static const struct file_operations graph_depth_fops = {

static __init int init_graph_tracefs(void)
{
	struct dentry *d_tracer;
	int ret;

	d_tracer = tracing_init_dentry();
	if (IS_ERR(d_tracer))
	ret = tracing_init_dentry();
	if (ret)
		return 0;

	trace_create_file("max_graph_depth", 0644, d_tracer,
	trace_create_file("max_graph_depth", 0644, NULL,
			  NULL, &graph_depth_fops);

	return 0;
Loading