Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2C6D393DC5 for ; Sun, 24 Aug 2025 01:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755997299; cv=none; b=FDM8WGPpNxJAoMgyR6XkcUbyhLXzEE4rcmSYrQWZiX8K2/B8NRhxb7UyM1jvFHd64gtRf++6F73bz5xbRoXjeTk20GD+NarHPN2c8Odd+pKLXrtm7xDZfrkUYckiKsDlTLZdJ7sN7UwYc/kXBhCpnDBw6eTSW0o/rHuEqD8od2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755997299; c=relaxed/simple; bh=ihPjMSxldWj+atpcya1Nseo5X6J0Hxe4Yk8SUDPyYTw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YQ1+ukMcSOmHwjL7SKaf4Ym9mznMS4uYnV9b/Z46GalRbZpG2W0L55fYzBZEynG6T7ojXQpjKgx2FgRwxAFebKSopXqIkjIP6YL6cWesQoq+bYH+8OYAJImfQ8qr/3shTDxAwSAM+tL46K3/6xtoZcVutxhQhe+VMEvVVrmrCZ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Yl1jzee0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Yl1jzee0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81E3EC4CEE7; Sun, 24 Aug 2025 01:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755997299; bh=ihPjMSxldWj+atpcya1Nseo5X6J0Hxe4Yk8SUDPyYTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yl1jzee0PW1EbHB0x8CnuEGOVAFUVPuzkGg5SGUcUS7qEFc24OyfU3vHZJtdnFCDD J2jjGdE7SGS4KKLguT4eDbWQugAs0jpfT0iGRRCouyYzsVsHnVxRiX2jE5syAsWqGW 0V0LhQO0qDdYD67Vo1vzX9ELVTZ/qcne0uisdblvQ6TvxDdc3CcZ9FljQzSK6upF5N rQKmOVyTtmYvUuoDx1fpRT8aU82wvNJqywb24YmCrCUUs5klmgXcvWqwmawBSoBu5i MWBSY16BRW7ELlYyeJ0csYKVqh+3eQkgIqQKizAtygGRezRgTmDX8NYEsIzxOL3ja5 RDdPPaHpsrgxg== From: Sasha Levin To: stable@vger.kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Sasha Levin Subject: [PATCH 6.16.y 1/2] tracing: Remove unneeded goto out logic Date: Sat, 23 Aug 2025 21:01:35 -0400 Message-ID: <20250824010136.2569554-1-sashal@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <2025082329-outgrow-powdered-a0e3@gregkh> References: <2025082329-outgrow-powdered-a0e3@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Steven Rostedt [ Upstream commit c89504a703fb779052213add0e8ed642f4a4f1c8 ] 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 Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Link: https://lore.kernel.org/20250801203857.538726745@kernel.org Signed-off-by: Steven Rostedt (Google) Stable-dep-of: 6a909ea83f22 ("tracing: Limit access to parser->buffer when trace_get_user failed") Signed-off-by: Sasha Levin --- kernel/trace/trace.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 7996f26c3f46..fafe0c436c74 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1846,7 +1846,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, ret = get_user(ch, ubuf++); if (ret) - goto out; + return ret; read++; cnt--; @@ -1860,7 +1860,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, while (cnt && isspace(ch)) { ret = get_user(ch, ubuf++); if (ret) - goto out; + return ret; read++; cnt--; } @@ -1870,8 +1870,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, /* only spaces were written */ if (isspace(ch) || !ch) { *ppos += read; - ret = read; - goto out; + return read; } } @@ -1879,13 +1878,12 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, while (cnt && !isspace(ch) && ch) { if (parser->idx < parser->size - 1) parser->buffer[parser->idx++] = ch; - else { - ret = -EINVAL; - goto out; - } + else + return -EINVAL; + ret = get_user(ch, ubuf++); if (ret) - goto out; + return ret; read++; cnt--; } @@ -1900,15 +1898,11 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, /* Make sure the parsed string always terminates with '\0'. */ parser->buffer[parser->idx] = 0; } else { - ret = -EINVAL; - goto out; + return -EINVAL; } *ppos += read; - ret = read; - -out: - return ret; + return read; } /* TODO add a seq_buf_to_buffer() */ @@ -2410,10 +2404,10 @@ int __init register_tracer(struct tracer *type) mutex_unlock(&trace_types_lock); if (ret || !default_bootup_tracer) - goto out_unlock; + return ret; if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE)) - goto out_unlock; + return 0; printk(KERN_INFO "Starting tracer '%s'\n", type->name); /* Do we want this tracer to start on bootup? */ @@ -2425,8 +2419,7 @@ int __init register_tracer(struct tracer *type) /* disable other selftests, since this will break it. */ disable_tracing_selftest("running a tracer"); - out_unlock: - return ret; + return 0; } 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, out_reg: ret = tracing_arm_snapshot(tr); if (ret < 0) - goto out; + return ret; ret = register_ftrace_function_probe(glob, tr, ops, count); if (ret < 0) tracing_disarm_snapshot(tr); - out: + return ret < 0 ? ret : 0; } @@ -11057,7 +11050,7 @@ __init static int tracer_alloc_buffers(void) BUILD_BUG_ON(TRACE_ITER_LAST_BIT > TRACE_FLAGS_MAX_SIZE); if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) - goto out; + return -ENOMEM; if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL)) goto out_free_buffer_mask; @@ -11175,7 +11168,6 @@ __init static int tracer_alloc_buffers(void) free_cpumask_var(global_trace.tracing_cpumask); out_free_buffer_mask: free_cpumask_var(tracing_buffer_mask); -out: return ret; } -- 2.50.1