From e49190c4933bdb4219c7fe5fb84768a076a1ff75 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 27 Mar 2012 14:09:14 -0700 Subject: [PATCH] Fix minor memory leaks found by valgrind. All of these leaks are in normally short-lived programs, so none of them is very important. Signed-off-by: Ben Pfaff --- lib/ovsdb-data.c | 3 ++- ovsdb/ovsdb-client.c | 9 +++++++++ ovsdb/ovsdb-tool.c | 4 ++++ utilities/ovs-ofctl.c | 3 +++ utilities/ovs-vsctl.c | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index bb8781c2..d9787185 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011 Nicira Networks +/* Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -590,6 +590,7 @@ ovsdb_atom_from_string(union ovsdb_atom *atom, error = ovsdb_atom_check_constraints(atom, base); if (error) { + ovsdb_atom_destroy(atom, base->type); msg = ovsdb_error_to_string(error); ovsdb_error_destroy(error); } diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index 53da6ae2..077e3a8c 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -885,10 +885,15 @@ dump_table(const struct ovsdb_table_schema *ts, struct json_array *rows) struct cell *cell = table_add_cell(&t); cell->json = ovsdb_datum_to_json(&data[y][x], &columns[x]->type); cell->type = &columns[x]->type; + ovsdb_datum_destroy(&data[y][x], &columns[x]->type); } + free(data[y]); } table_print(&t, &table_style); table_destroy(&t); + + free(data); + free(columns); } static void @@ -957,6 +962,10 @@ do_dump(struct jsonrpc *rpc, const char *database, dump_table(ts, &rows->u.array); } + + jsonrpc_msg_destroy(reply); + free(tables); + ovsdb_schema_destroy(schema); } static void diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index ecf998b3..e83b49a1 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -252,6 +252,10 @@ compact_or_convert(const char *src_name, const char *dst_name, } lockfile_unlock(dst_lock); + + if (in_place) { + free((char *) dst_name); + } } static void diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 3e9f4628..2b91a289 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -363,6 +363,7 @@ dump_transaction(const char *vconn_name, struct ofpbuf *request) open_vconn(vconn_name, &vconn); run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name); ofp_print(stdout, reply->data, reply->size, verbosity + 1); + ofpbuf_delete(reply); vconn_close(vconn); } @@ -1135,6 +1136,7 @@ do_packet_out(int argc, char *argv[]) ofpbuf_delete(packet); } vconn_close(vconn); + ofpbuf_uninit(&actions); } static void @@ -1413,6 +1415,7 @@ fte_free_all(struct classifier *cls) classifier_remove(cls, &fte->rule); fte_free(fte); } + classifier_destroy(cls); } /* Searches 'cls' for an FTE matching 'rule', inserting a new one if diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 0caf57e8..d752a547 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -1370,6 +1370,7 @@ cmd_add_br(struct vsctl_context *ctx) br_name, parent_name, vlan, br_name, br->vlan); } } + free_info(&info); return; } } @@ -1730,6 +1731,7 @@ add_port(struct vsctl_context *ctx, svec_destroy(&want_names); svec_destroy(&have_names); + free_info(&info); return; } @@ -3540,6 +3542,7 @@ is_condition_satisfied(const struct vsctl_table_class *table, } ovsdb_atom_destroy(&want_key, column->type.key.type); + ovsdb_datum_destroy(&b, &type); } else { struct ovsdb_datum want_datum; -- 2.30.2