linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] synthetic tracing: Fix trace_string() return value
@ 2024-02-14 22:05 Thorsten Blum
  2024-02-15 13:37 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2024-02-14 22:05 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel, Thorsten Blum

Fix trace_string() by assigning the string length to the return variable
which got lost in commit ddeea494a16f ("tracing/synthetic: Use union
instead of casts") and caused trace_string() to always return 0.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 kernel/trace/trace_events_synth.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index e7af286af4f1..c82b401a294d 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -441,8 +441,9 @@ static unsigned int trace_string(struct synth_trace_event *entry,
 	if (is_dynamic) {
 		union trace_synth_field *data = &entry->fields[*n_u64];
 
+		len = fetch_store_strlen((unsigned long)str_val);
 		data->as_dynamic.offset = struct_size(entry, fields, event->n_u64) + data_size;
-		data->as_dynamic.len = fetch_store_strlen((unsigned long)str_val);
+		data->as_dynamic.len = len;
 
 		ret = fetch_store_string((unsigned long)str_val, &entry->fields[*n_u64], entry);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] synthetic tracing: Fix trace_string() return value
  2024-02-14 22:05 [PATCH] synthetic tracing: Fix trace_string() return value Thorsten Blum
@ 2024-02-15 13:37 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2024-02-15 13:37 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Steven Rostedt, Mathieu Desnoyers, linux-kernel, linux-trace-kernel

On Wed, 14 Feb 2024 23:05:56 +0100
Thorsten Blum <thorsten.blum@toblux.com> wrote:

> Fix trace_string() by assigning the string length to the return variable
> which got lost in commit ddeea494a16f ("tracing/synthetic: Use union
> instead of casts") and caused trace_string() to always return 0.
> 

Good catch!

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Fixes: ddeea494a16f ("tracing/synthetic: Use union instead of casts")
Cc: stable@vger.kernel.org

Thanks!

> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
>  kernel/trace/trace_events_synth.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
> index e7af286af4f1..c82b401a294d 100644
> --- a/kernel/trace/trace_events_synth.c
> +++ b/kernel/trace/trace_events_synth.c
> @@ -441,8 +441,9 @@ static unsigned int trace_string(struct synth_trace_event *entry,
>  	if (is_dynamic) {
>  		union trace_synth_field *data = &entry->fields[*n_u64];
>  
> +		len = fetch_store_strlen((unsigned long)str_val);
>  		data->as_dynamic.offset = struct_size(entry, fields, event->n_u64) + data_size;
> -		data->as_dynamic.len = fetch_store_strlen((unsigned long)str_val);
> +		data->as_dynamic.len = len;
>  
>  		ret = fetch_store_string((unsigned long)str_val, &entry->fields[*n_u64], entry);
>  
> -- 
> 2.39.2
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-15 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 22:05 [PATCH] synthetic tracing: Fix trace_string() return value Thorsten Blum
2024-02-15 13:37 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).