Skip to content

Commit a970a8a

Browse files
rostedtgregkh
authored andcommitted
tracing: Remove unneeded goto out logic
[ Upstream commit c89504a ] Several places in the trace.c file there's a goto out where the out is simply a return. There's no reason to jump to the out label if it's not doing any more logic but simply returning from the function. Replace the goto outs with a return and remove the out labels. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://lore.kernel.org/20250801203857.538726745@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Stable-dep-of: 6a909ea ("tracing: Limit access to parser->buffer when trace_get_user failed") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5af0b2a commit a970a8a

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

kernel/trace/trace.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18461846

18471847
ret = get_user(ch, ubuf++);
18481848
if (ret)
1849-
goto out;
1849+
return ret;
18501850

18511851
read++;
18521852
cnt--;
@@ -1860,7 +1860,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18601860
while (cnt && isspace(ch)) {
18611861
ret = get_user(ch, ubuf++);
18621862
if (ret)
1863-
goto out;
1863+
return ret;
18641864
read++;
18651865
cnt--;
18661866
}
@@ -1870,22 +1870,20 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18701870
/* only spaces were written */
18711871
if (isspace(ch) || !ch) {
18721872
*ppos += read;
1873-
ret = read;
1874-
goto out;
1873+
return read;
18751874
}
18761875
}
18771876

18781877
/* read the non-space input */
18791878
while (cnt && !isspace(ch) && ch) {
18801879
if (parser->idx < parser->size - 1)
18811880
parser->buffer[parser->idx++] = ch;
1882-
else {
1883-
ret = -EINVAL;
1884-
goto out;
1885-
}
1881+
else
1882+
return -EINVAL;
1883+
18861884
ret = get_user(ch, ubuf++);
18871885
if (ret)
1888-
goto out;
1886+
return ret;
18891887
read++;
18901888
cnt--;
18911889
}
@@ -1900,15 +1898,11 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
19001898
/* Make sure the parsed string always terminates with '\0'. */
19011899
parser->buffer[parser->idx] = 0;
19021900
} else {
1903-
ret = -EINVAL;
1904-
goto out;
1901+
return -EINVAL;
19051902
}
19061903

19071904
*ppos += read;
1908-
ret = read;
1909-
1910-
out:
1911-
return ret;
1905+
return read;
19121906
}
19131907

19141908
/* TODO add a seq_buf_to_buffer() */
@@ -2410,10 +2404,10 @@ int __init register_tracer(struct tracer *type)
24102404
mutex_unlock(&trace_types_lock);
24112405

24122406
if (ret || !default_bootup_tracer)
2413-
goto out_unlock;
2407+
return ret;
24142408

24152409
if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE))
2416-
goto out_unlock;
2410+
return 0;
24172411

24182412
printk(KERN_INFO "Starting tracer '%s'\n", type->name);
24192413
/* Do we want this tracer to start on bootup? */
@@ -2425,8 +2419,7 @@ int __init register_tracer(struct tracer *type)
24252419
/* disable other selftests, since this will break it. */
24262420
disable_tracing_selftest("running a tracer");
24272421

2428-
out_unlock:
2429-
return ret;
2422+
return 0;
24302423
}
24312424

24322425
static void tracing_reset_cpu(struct array_buffer *buf, int cpu)
@@ -8954,12 +8947,12 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash,
89548947
out_reg:
89558948
ret = tracing_arm_snapshot(tr);
89568949
if (ret < 0)
8957-
goto out;
8950+
return ret;
89588951

89598952
ret = register_ftrace_function_probe(glob, tr, ops, count);
89608953
if (ret < 0)
89618954
tracing_disarm_snapshot(tr);
8962-
out:
8955+
89638956
return ret < 0 ? ret : 0;
89648957
}
89658958

@@ -11057,7 +11050,7 @@ __init static int tracer_alloc_buffers(void)
1105711050
BUILD_BUG_ON(TRACE_ITER_LAST_BIT > TRACE_FLAGS_MAX_SIZE);
1105811051

1105911052
if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
11060-
goto out;
11053+
return -ENOMEM;
1106111054

1106211055
if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL))
1106311056
goto out_free_buffer_mask;
@@ -11175,7 +11168,6 @@ __init static int tracer_alloc_buffers(void)
1117511168
free_cpumask_var(global_trace.tracing_cpumask);
1117611169
out_free_buffer_mask:
1117711170
free_cpumask_var(tracing_buffer_mask);
11178-
out:
1117911171
return ret;
1118011172
}
1118111173

0 commit comments

Comments
 (0)