2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 22:35:15 +00:00

ovsdb-idl: Fix issues detected in Partial Map Update feature

We found some issues affecting Partial Map Update feature included in
master branch.  This patch fixes a memory leak due to lack of freeing datum
allocated in the process of requesting a change to a map.  It also fix an
error produced when NDEBUG flag is not set that causes an assertion when
preparing the map to be changed.

Fix of a memory leak not freeing datums.
Change use of ovsdb_idl_read function when preparing changes to maps.

Signed-off-by: arnoldo.lutz.guevara@hpe.com <arnoldo.lutz.guevara@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Lutz, Arnoldo
2016-06-13 16:06:48 +00:00
committed by Ben Pfaff
parent a12e2a88d6
commit b1048e6af1
3 changed files with 13 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ Ansis Atteka aatteka@nicira.com
Antonio Fischetti antonio.fischetti@intel.com
Anupam Chanda achanda@nicira.com
Ariel Tubaltsev atubaltsev@vmware.com
Arnoldo Lutz arnoldo.lutz.guevara@hpe.com
Arun Sharma arun.sharma@calsoftinc.com
Aryan TaheriMonfared aryan.taherimonfared@uis.no
Ashwin Swaminathan ashwinds@arista.com

View File

@@ -2226,7 +2226,15 @@ ovsdb_idl_txn_extract_mutations(struct ovsdb_idl_row *row,
column = &class->columns[idx];
key_type = column->type.key.type;
value_type = column->type.value.type;
old_datum = ovsdb_idl_read(row, column);
/* Get the value to be changed */
if (row->new && row->written && bitmap_is_set(row->written,idx)) {
old_datum = &row->new[idx];
} else if (row->old != NULL) {
old_datum = &row->old[idx];
} else {
old_datum = ovsdb_datum_default(&column->type);
}
del_set = json_array_create_empty();
ins_map = json_array_create_empty();
@@ -3408,6 +3416,7 @@ ovsdb_idl_txn_write_partial_map(const struct ovsdb_idl_row *row_,
if (!is_valid_partial_update(row, column, datum)) {
ovsdb_datum_destroy(datum, &column->type);
free(datum);
return;
}
@@ -3438,6 +3447,7 @@ ovsdb_idl_txn_delete_partial_map(const struct ovsdb_idl_row *row_,
struct ovsdb_type type_ = column->type;
type_.value.type = OVSDB_TYPE_VOID;
ovsdb_datum_destroy(datum, &type_);
free(datum);
return;
}
ovsdb_idl_txn_add_map_op(row, column, datum, MAP_OP_DELETE);

View File

@@ -57,6 +57,7 @@ map_op_destroy_datum(struct map_op *map_op, const struct ovsdb_type *type)
} else {
ovsdb_datum_destroy(map_op->datum, type);
}
free(map_op->datum);
map_op->datum = NULL;
}