[ovs-dev] [PATCH 1/1] ovn-nbctl: fix memory leak

Damijan Skvarc damjan.skvarc at gmail.com
Wed Jul 3 11:50:40 UTC 2019


Patch is mostly intended to prevent valgrind to report memory leak issues
while running unit tests. Otherwise it does not benefit anything since 
the application exits immediately after freeing the memory.

Signed-off-by: Damijan Skvarc <damjan.skvarc at gmail.com>
---
 ovn/utilities/ovn-nbctl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index e86ab7f..98a8faa 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -156,6 +156,7 @@ main(int argc, char *argv[])
     char *error_s = ovs_cmdl_parse_all(argc, argv, get_all_options(),
                                        &parsed_options, &n_parsed_options);
     if (error_s) {
+        free(args);
         ctl_fatal("%s", error_s);
     }
 
@@ -181,6 +182,7 @@ main(int argc, char *argv[])
     bool daemon_mode = false;
     if (get_detach()) {
         if (argc != optind) {
+            free(args);
             ctl_fatal("non-option arguments not supported with --detach "
                       "(use --help for help)");
         }
@@ -203,6 +205,7 @@ main(int argc, char *argv[])
         error = ctl_parse_commands(argc - optind, argv + optind,
                                    &local_options, &commands, &n_commands);
         if (error) {
+            free(args);
             ctl_fatal("%s", error);
         }
         VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG,
@@ -212,11 +215,13 @@ main(int argc, char *argv[])
 
         error = run_prerequisites(commands, n_commands, idl);
         if (error) {
+            free(args);
             ctl_fatal("%s", error);
         }
 
         error = main_loop(args, commands, n_commands, idl, NULL);
         if (error) {
+            free(args);
             ctl_fatal("%s", error);
         }
 
-- 
2.7.4



More information about the dev mailing list