Commit 2335ee93 authored by Ben Pfaff's avatar Ben Pfaff

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: default avatarBen Pfaff <blp@ovn.org>
Acked-by: default avatarWilliam Tu <u9012063@gmail.com>
parent 05b1dd23
......@@ -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
......
......@@ -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[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment