From 1d12100d047b079e7425bd4bfdc8572dcfbbd4c8 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Tue, 18 Oct 2016 18:09:53 -0400 Subject: [PATCH] Fix: save: leak of configuration file fd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/save.c | 7 +++++++ src/common/config/session-config.h | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 9ac7712cb..1a879b214 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -2053,6 +2053,13 @@ end: } } + if (file_opened) { + ret = close(fd); + if (ret) { + PERROR("Closing XML session configuration"); + } + } + return ret; } diff --git a/src/common/config/session-config.h b/src/common/config/session-config.h index c6439f756..f48ff74ae 100644 --- a/src/common/config/session-config.h +++ b/src/common/config/session-config.h @@ -85,8 +85,8 @@ int config_parse_value(const char *value); /* * Create an instance of a configuration writer. * - * fd_output File to which the XML content must be written. The file will be - * closed once the config_writer has been destroyed. + * fd_output File to which the XML content must be written. fd_output is + * owned by the caller. * * indent If other than 0 the XML will be pretty printed * with indentation and newline. -- 2.34.1