]> git.proxmox.com Git - mirror_ovs.git/commitdiff
trigger: Free leaked ovsdb_schema
authorYifeng Sun <pkusunyifeng@gmail.com>
Wed, 11 Sep 2019 21:18:31 +0000 (14:18 -0700)
committerBen Pfaff <blp@ovn.org>
Thu, 19 Sep 2019 16:23:49 +0000 (09:23 -0700)
Valgrind reported:

1925: schema conversion online - standalone

==10884== 689 (56 direct, 633 indirect) bytes in 1 blocks are definitely lost in loss record 384 of 420
==10884==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10884==    by 0x44A592: xcalloc (util.c:121)
==10884==    by 0x40E2EC: ovsdb_schema_create (ovsdb.c:41)
==10884==    by 0x40E688: ovsdb_schema_from_json (ovsdb.c:217)
==10884==    by 0x416C6F: ovsdb_trigger_try (trigger.c:246)
==10884==    by 0x40D4DE: ovsdb_jsonrpc_trigger_create (jsonrpc-server.c:1119)
==10884==    by 0x40D4DE: ovsdb_jsonrpc_session_got_request (jsonrpc-server.c:986)
==10884==    by 0x40D4DE: ovsdb_jsonrpc_session_run (jsonrpc-server.c:556)
==10884==    by 0x40D4DE: ovsdb_jsonrpc_session_run_all (jsonrpc-server.c:586)
==10884==    by 0x40D4DE: ovsdb_jsonrpc_server_run (jsonrpc-server.c:401)
==10884==    by 0x406A6E: main_loop (ovsdb-server.c:209)
==10884==    by 0x406A6E: main (ovsdb-server.c:460)

'new_schema' should also be freed when there is no error.
This patch fixes it.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ovsdb/trigger.c

index 6f4ed96b000be1bc4431a93fd742e800f5a399b6..7e62e90ae381014b6caea4890ee406031126f9e6 100644 (file)
@@ -254,8 +254,8 @@ ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now)
             if (!error) {
                 error = ovsdb_convert(t->db, new_schema, &newdb);
             }
+            ovsdb_schema_destroy(new_schema);
             if (error) {
-                ovsdb_schema_destroy(new_schema);
                 trigger_convert_error(t, error);
                 return false;
             }