[ovs-dev] [PATCH 1/1] ovsdb-client: fix memory leak in do_needs_conversion() and do_convert()

Damijan Skvarc damjan.skvarc at gmail.com
Mon Sep 30 08:21:00 UTC 2019


Memory leak itself is not so important, however the problem is that
it is caused by forgetting to close rpc channel which might in
a long term lead to the leak of system resources.

Memory leak is reported by Valgrin running test suite and is expressed as:

==29472== 784 (600 direct, 184 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 23
==29472==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29472==    by 0x449D32: xcalloc (util.c:121)
==29472==    by 0x432147: jsonrpc_open (jsonrpc.c:87)
==29472==    by 0x40ABBE: open_jsonrpc (ovsdb-client.c:528)
==29472==    by 0x40ABBE: open_rpc (ovsdb-client.c:143)
==29472==    by 0x40AE50: do_needs_conversion (ovsdb-client.c:1670)
==29472==    by 0x405F76: main (ovsdb-client.c:282)

==29464== 784 (600 direct, 184 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 23
==29464==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29464==    by 0x449D32: xcalloc (util.c:121)
==29464==    by 0x432147: jsonrpc_open (jsonrpc.c:87)
==29464==    by 0x40ABBE: open_jsonrpc (ovsdb-client.c:528)
==29464==    by 0x40ABBE: open_rpc (ovsdb-client.c:143)
==29464==    by 0x40AF5A: do_convert (ovsdb-client.c:1644)
==29464==    by 0x405F76: main (ovsdb-client.c:282)

Signed-off-by: Damijan Skvarc <damjan.skvarc at gmail.com>
---
 ovsdb/ovsdb-client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index e3ef372..e78e9d9 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -1657,6 +1657,7 @@ do_convert(struct jsonrpc *rpc, const char *database_ OVS_UNUSED,
     check_txn(jsonrpc_transact_block(rpc, request, &reply), &reply);
     jsonrpc_msg_destroy(reply);
     ovsdb_schema_destroy(new_schema);
+    jsonrpc_close(rpc);
 }
 
 static void
@@ -1677,6 +1678,7 @@ do_needs_conversion(struct jsonrpc *rpc, const char *database_ OVS_UNUSED,
     puts(ovsdb_schema_equal(schema1, schema2) ? "no" : "yes");
     ovsdb_schema_destroy(schema1);
     ovsdb_schema_destroy(schema2);
+    jsonrpc_close(rpc);
 }
 
 struct dump_table_aux {
-- 
2.7.4



More information about the dev mailing list