Skip to content

Commit

Permalink
ovsdb-idl: Fix issues detected in Partial Map Update feature
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ArnoldoLutz authored and blp committed Jun 24, 2016
1 parent a12e2a8 commit b1048e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion lib/ovsdb-idl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/ovsdb-map-op.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b1048e6

Please sign in to comment.