aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2016-11-15 16:32:29 -0500
committerSteven Rostedt <rostedt@goodmis.org>2016-11-15 16:32:29 -0500
commit67b3610542f5b9ca4c87d46b2a02173025837c43 (patch)
treef9c0eb93e325f9e1f8149b39d441b7c16d71dbdf
parent8cfd82f1c16287f56f4a57306d2c709c5df1b099 (diff)
downloadtrace-cmd-67b3610542f5b9ca4c87d46b2a02173025837c43.tar.gz
trace-cmd: Fix file pointer leak on error exit of tracecmd_find_tracing_dir()
If the strdup() fails to allocate, we exit tracecmd_find_tracing_dir() without closing the file descriptor just opened. Reported-by: David Binderman <dcb314@hotmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/trace-util.c b/trace-util.c
index 5bf591c0..14656d9a 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -723,8 +723,10 @@ char *tracecmd_find_tracing_dir(void)
break;
if (!debug_str && strcmp(type, "debugfs") == 0) {
debug_str = strdup(fspath);
- if (!debug_str)
+ if (!debug_str) {
+ fclose(fp);
return NULL;
+ }
}
}
fclose(fp);