[PATCH] trace-cmd sqlhist: Initialize err value to tracefs_sql()

Steven Rostedt <[email protected]> Thu, 10 Apr 2025 09:38:10 -0400
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
From: "Steven Rostedt (Google)" <[email protected]>

If tracefs_sql() fails, it doesn't always initialize the passed in "err"
pointer. That should be set to NULL before passing it in otherwise it can't
be known if the function set it on error.

Fixes: 1d5ac88ee ("trace-cmd sqlhist: Add 'sqlhist' command")
Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
 tracecmd/trace-sqlhist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tracecmd/trace-sqlhist.c b/tracecmd/trace-sqlhist.c
index 9f2b94e6..ee7eed82 100644
--- a/tracecmd/trace-sqlhist.c
+++ b/tracecmd/trace-sqlhist.c
@@ -28,7 +28,7 @@ static int do_sql(const char *instance_name,
 	struct tep_handle *tep;
 	struct trace_seq seq;
 	enum tracefs_synth_handler handler;
-	char *err;
+	char *err = NULL;
 	int ret;
 
 	if ((action & ACTIONS) && !var)
-- 
2.47.2