From 2335ee9347188fef7cc68d0db3228f1b970518a3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 25 Jan 2018 15:39:47 -0800 Subject: ovs-vsctl, vtep-ctl: Free 'args' string on exit. This avoids a memory leak warning from valgrind. ovn-sbctl and ovn-nbctl already followed this pattern. Signed-off-by: Ben Pfaff Acked-by: William Tu --- utilities/ovs-vsctl.c | 12 ++++++++---- vtep/vtep-ctl.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 7b909431d..6e47ca361 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -97,7 +97,7 @@ OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); static void run_prerequisites(struct ctl_command[], size_t n_commands, struct ovsdb_idl *); -static void do_vsctl(const char *args, struct ctl_command *, size_t n, +static bool do_vsctl(const char *args, struct ctl_command *, size_t n, struct ovsdb_idl *); /* post_db_reload_check frame work is to allow ovs-vsctl to do additional @@ -181,7 +181,10 @@ main(int argc, char *argv[]) if (seqno != ovsdb_idl_get_seqno(idl)) { seqno = ovsdb_idl_get_seqno(idl); - do_vsctl(args, commands, n_commands, idl); + if (do_vsctl(args, commands, n_commands, idl)) { + free(args); + exit(EXIT_SUCCESS); + } } if (seqno == ovsdb_idl_get_seqno(idl)) { @@ -2482,7 +2485,7 @@ vsctl_parent_process_info(void) #endif } -static void +static bool do_vsctl(const char *args, struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl) { @@ -2666,7 +2669,7 @@ do_vsctl(const char *args, struct ctl_command *commands, size_t n_commands, ovsdb_idl_txn_destroy(txn); ovsdb_idl_destroy(idl); - exit(EXIT_SUCCESS); + return true; try_again: /* Our transaction needs to be rerun, or a prerequisite was not met. Free @@ -2682,6 +2685,7 @@ try_again: free(c->table); } free(error); + return false; } /* Frees the current transaction and the underlying IDL and then calls diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 3af71498b..056dc687a 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -82,7 +82,7 @@ OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); static void run_prerequisites(struct ctl_command[], size_t n_commands, struct ovsdb_idl *); -static void do_vtep_ctl(const char *args, struct ctl_command *, size_t n, +static bool do_vtep_ctl(const char *args, struct ctl_command *, size_t n, struct ovsdb_idl *); static struct vtep_ctl_lswitch *find_lswitch(struct vtep_ctl_context *, const char *name, @@ -144,7 +144,10 @@ main(int argc, char *argv[]) if (seqno != ovsdb_idl_get_seqno(idl)) { seqno = ovsdb_idl_get_seqno(idl); - do_vtep_ctl(args, commands, n_commands, idl); + if (do_vtep_ctl(args, commands, n_commands, idl)) { + free(args); + exit(EXIT_SUCCESS); + } } if (seqno == ovsdb_idl_get_seqno(idl)) { @@ -2257,7 +2260,7 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, } } -static void +static bool do_vtep_ctl(const char *args, struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl) { @@ -2405,7 +2408,7 @@ do_vtep_ctl(const char *args, struct ctl_command *commands, ovsdb_idl_destroy(idl); - exit(EXIT_SUCCESS); + return true; try_again: /* Our transaction needs to be rerun, or a prerequisite was not met. Free @@ -2421,6 +2424,7 @@ try_again: free(c->table); } free(error); + return false; } static const struct ctl_command_syntax vtep_commands[] = { -- cgit v1.2.1