mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
db-ctl-base: Free leaked ovsdb_datum
Valgrind reported: 2491: database commands -- negative checks ==19245== 36 (32 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 36 of 53 ==19245== at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==19245== by 0x431AB4: xrealloc (util.c:149) ==19245== by 0x41656D: ovsdb_datum_reallocate (ovsdb-data.c:1883) ==19245== by 0x41656D: ovsdb_datum_union (ovsdb-data.c:1961) ==19245== by 0x4107B2: cmd_add (db-ctl-base.c:1494) ==19245== by 0x406E2E: do_vsctl (ovs-vsctl.c:2626) ==19245== by 0x406E2E: main (ovs-vsctl.c:183) ==19252== 16 bytes in 1 blocks are definitely lost in loss record 9 of 52 ==19252== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==19252== by 0x430F74: xmalloc (util.c:138) ==19252== by 0x414D07: clone_atoms (ovsdb-data.c:990) ==19252== by 0x4153F6: ovsdb_datum_clone (ovsdb-data.c:1012) ==19252== by 0x4104D3: cmd_remove (db-ctl-base.c:1564) ==19252== by 0x406E2E: do_vsctl (ovs-vsctl.c:2626) ==19252== by 0x406E2E: main (ovs-vsctl.c:183) This patch fixes them. Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -1505,6 +1505,7 @@ cmd_add(struct ctl_context *ctx)
|
||||
ctx->error = ovsdb_datum_from_string(&add, &add_type, ctx->argv[i],
|
||||
ctx->symtab);
|
||||
if (ctx->error) {
|
||||
ovsdb_datum_destroy(&old, &column->type);
|
||||
return;
|
||||
}
|
||||
ovsdb_datum_union(&old, &add, type, false);
|
||||
@@ -1516,6 +1517,7 @@ cmd_add(struct ctl_context *ctx)
|
||||
old.n,
|
||||
type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs",
|
||||
column->name, table->name, type->n_max);
|
||||
ovsdb_datum_destroy(&old, &column->type);
|
||||
return;
|
||||
}
|
||||
ovsdb_idl_txn_verify(row, column);
|
||||
@@ -1597,10 +1599,12 @@ cmd_remove(struct ctl_context *ctx)
|
||||
ctx->argv[i],
|
||||
ctx->symtab);
|
||||
if (ctx->error) {
|
||||
ovsdb_datum_destroy(&old, &column->type);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ctx->error = error;
|
||||
ovsdb_datum_destroy(&old, &column->type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1612,6 +1616,7 @@ cmd_remove(struct ctl_context *ctx)
|
||||
"table %s but the minimum number is %u", old.n,
|
||||
type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs",
|
||||
column->name, table->name, type->n_min);
|
||||
ovsdb_datum_destroy(&old, &column->type);
|
||||
return;
|
||||
}
|
||||
ovsdb_idl_txn_verify(row, column);
|
||||
|
Reference in New Issue
Block a user