[ovs-dev] [PATCHv3 1/3] ovsdb-idl: Fix memory leak

Yifeng Sun pkusunyifeng at gmail.com
Tue Oct 31 17:52:08 UTC 2017


Valgrind testcase 2339 (ovn -- ipam connectivity) reports the leak below:
45 (32 direct, 13 indirect) bytes in 1 blocks are definitely lost in loss record 65 of 83
    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4A6D64: xmalloc (util.c:120)
    by 0x49C847: shash_add_nocopy__ (shash.c:109)
    by 0x49C847: shash_add_nocopy (shash.c:121)
    by 0x49CA85: shash_add (shash.c:129)
    by 0x49CA85: shash_add_once (shash.c:136)
    by 0x4914B5: ovsdb_idl_create_index (ovsdb-idl.c:2067)
    by 0x406C98: create_ovnsb_indexes (ovn-controller.c:568)
    by 0x406C98: main (ovn-controller.c:619)

The leak happens when vsdb_idl_table is freed but its indexes are not freed.

v1->v2: Amend comments.
v2->v3: Fix error in patch.

Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
---
 lib/ovsdb-idl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 5617e08d633c..be29c92957c0 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -2163,6 +2163,7 @@ ovsdb_idl_destroy_indexes(struct ovsdb_idl_table *table)
         skiplist_destroy(index->skiplist, NULL);
         free(index->columns);
     }
+    shash_destroy_free_data(&table->indexes);
 }
 
 static void
-- 
2.7.4



More information about the dev mailing list