Close fd if the allocation of file2 fails in __tracecmd_create_buffer_recorder(). Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- lib/trace-cmd/trace-recorder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.47.0
![]() |