]> git.proxmox.com Git - ovs.git/commitdiff
ovsdb-idl: Fix issues detected in Partial Map Update feature
authorLutz, Arnoldo <arnoldo.lutz.guevara@hpe.com>
Mon, 13 Jun 2016 16:06:48 +0000 (16:06 +0000)
committerBen Pfaff <blp@ovn.org>
Fri, 24 Jun 2016 21:21:35 +0000 (14:21 -0700)
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>
AUTHORS
lib/ovsdb-idl.c
lib/ovsdb-map-op.c

diff --git a/AUTHORS b/AUTHORS
index c39fdd3dbd398fbf61b536bbf40a7694309a7382..628264599db57ba9d52fc007c2a0fc6f58d91829 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -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
index b14bef270db5d3c2cc359501930011ead35b299a..9b3e93384dc1140ef57cd47dd3cd0239e38b32f3 100644 (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);
index 58f43dcda52392f7739ea9ed3da32c1a14a9b294..23fc5f526599ec3da8db9f0c35dc74b21dc36e28 100644 (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;
 }