[PATCH] trace-cmd split: Initialize current in parse_file()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxx/

Fixes: 1439b8f518 ("trace-cmd split: Correctly split with start/end/time-window parameters")
Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux