All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Subject: [PATCH] trace-cmd split: Initialize current in parse_file()
Date: Wed, 24 Jan 2024 12:34:39 -0500	[thread overview]
Message-ID: <20240124123439.3441eb6f@gandalf.local.home> (raw)

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The code fix to correctly split start/end/time-window parameters removed
an initialization of "current" which can now fall out being uninitialized
and used for a later compare.

Found with valgrind that reported uninitialized variable in the loop condition:

	do {
		if (repeat)
			sprintf(output_file, "%s.%04d", output, c++);
		else
			strcpy(output_file, output);
			
		current = parse_file(handle, output_file, start_ns, end_ns,
				     percpu, cpu, count, type, &end_reached);

		if (!repeat)
			break;
		start_ns = 0;
	} while (!end_reached && (current && (!end_ns || current < end_ns)));

Link: https://lore.kernel.org/linux-trace-devel/20240124122832.4e0b33b7@gandalf.local.home/

Fixes: 1439b8f518 ("trace-cmd split: Correctly split with start/end/time-window parameters")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-split.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index 0820a3bb0721..2c311b3d6be3 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -480,7 +480,7 @@ static unsigned long long parse_file(struct tracecmd_input *handle,
 				     enum split_types type,
 				     bool *end_reached)
 {
-	unsigned long long current;
+	unsigned long long current = 0;
 	struct handle_list *handle_entry;
 	struct tracecmd_output *ohandle;
 	struct cpu_data *cpu_data;
-- 
2.43.0


                 reply	other threads:[~2024-01-24 17:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240124123439.3441eb6f@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=pierre.gondois@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.