diff options
author | Damijan Skvarc <damjan.skvarc@gmail.com> | 2019-10-02 13:44:49 +0200 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2019-10-02 07:54:22 -0700 |
commit | 1bbc32df4b56b57a9685fe2e26dd5bfb70de1f03 (patch) | |
tree | f7e1c84f82110fb0e60e159e73a7e2f6edbf4bda | |
parent | e7ea37ac922b0873942fab34a4cb81fe05667073 (diff) | |
download | openvswitch-1bbc32df4b56b57a9685fe2e26dd5bfb70de1f03.tar.gz |
vlog: fix memory leak in vlog_set_log_file() function
memory leak happens in case previously closed log file was reopened again,
for example:
ovs-appctl vlog/close
ovs-appctl vlog/reopen
memory leak is reported by valgrind in a form:
==4463== 76 bytes in 1 blocks are definitely lost in loss record 322 of 344
==4463== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4463== by 0x534314: xmalloc (util.c:138)
==4463== by 0x534384: xmemdup0 (util.c:168)
==4463== by 0x53ACB9: vlog_set_log_file (vlog.c:403)
==4463== by 0x53AEDC: vlog_reopen_log_file (vlog.c:434)
==4463== by 0x53AF22: vlog_unixctl_reopen (vlog.c:683)
==4463== by 0x533730: process_command (unixctl.c:308)
==4463== by 0x533730: run_connection (unixctl.c:342)
==4463== by 0x533730: unixctl_server_run (unixctl.c:393)
==4463== by 0x4073AE: main (ovs-vswitchd.c:128)
Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | lib/vlog.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/vlog.c b/lib/vlog.c index 01cfdc5d3..559943d87 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -395,11 +395,11 @@ vlog_set_log_file(const char *file_name) /* Close old log file, if any, and install new one. */ ovs_mutex_lock(&log_file_mutex); if (log_fd >= 0) { - free(log_file_name); close(log_fd); async_append_destroy(log_writer); } + free(log_file_name); log_file_name = xstrdup(new_log_file_name); log_fd = new_log_fd; if (log_async) { |