Message ID | 20241205144439.127564-4-jmarchan@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | trace-cmd: Fix misc issues uncoverd by static analysis | expand |
diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c index 0413e529..f02c3a55 100644 --- a/lib/trace-cmd/trace-recorder.c +++ b/lib/trace-cmd/trace-recorder.c @@ -193,8 +193,10 @@ __tracecmd_create_buffer_recorder(const char *file, int cpu, unsigned flags, int len = strlen(file); file2 = malloc(len + 3); - if (!file2) + if (!file2) { + close(fd); return NULL; + } sprintf(file2, "%s.1", file);
Close fd if the allocation of file2 fails in __tracecmd_create_buffer_recorder(). Signed-off-by: Jerome Marchand <jmarchan@redhat.com> --- lib/trace-cmd/trace-recorder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)