Skip to contentSkip to conversation

trace-cmd: avoid using uninitialized handle

PATCH In review Greg Thelen 2 participants 2 messages Jun 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: avoid using uninitialized handle

The put_together_file() 'out' error path uses uninitialized handle. Unconditionally initialize handle.

Fixes 9ed499fccef5 ("trace-cmd: Fix record --date flag when sending tracing data to a listener")
---
 tracecmd/trace-listen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-listen.c +1 -1
index 3106022eeb39..9132582768ac 100644
@@ -626,7 +626,7 @@ static void stop_all_readers(int cpus, int *pid_array)
 static int put_together_file(int cpus, int ofd, const char *node,
 			     const char *port, bool write_options)
 {
-	struct tracecmd_output *handle;
+	struct tracecmd_output *handle = NULL;
 	char **temp_files;
 	int cpu;
 	int ret = -ENOMEM;
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
#1 lore raw
Quoted 2 lines · On Thu, 27 Jun 2019 08:27:10 -0700 Greg Thelen <[email protected]> wrote:

The put_together_file() 'out' error path uses uninitialized handle. Unconditionally initialize handle.

Yep, that's true.

Quoted 2 lines
Fixes 9ed499fccef5 ("trace-cmd: Fix record --date flag when sending tracing data to a listener")

Thanks, I'll add this to the queue.

-- Steve

Quoted 18 lines
---
 tracecmd/trace-listen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-listen.c +1 -1
index 3106022eeb39..9132582768ac 100644
@@ -626,7 +626,7 @@ static void stop_all_readers(int cpus, int *pid_array)
 static int put_together_file(int cpus, int ofd, const char *node,
 			     const char *port, bool write_options)
 {
-	struct tracecmd_output *handle;
+	struct tracecmd_output *handle = NULL;
 	char **temp_files;
 	int cpu;
 	int ret = -ENOMEM;