summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorWilliam Tu <u9012063@gmail.com>2020-05-02 09:08:26 -0700
committerWilliam Tu <u9012063@gmail.com>2020-05-12 08:35:22 -0700
commit11827c63e22e6f668379dc74260a84f68940275c (patch)
tree196093f2415affb3310726dc9a5c0dbcb7d62609 /ovsdb
parent6187bd3aa00dff30b7db3414381e750ecf8ab777 (diff)
downloadopenvswitch-11827c63e22e6f668379dc74260a84f68940275c.tar.gz
ovsdb-idlc: Fix memory leak reported by Coverity.
An exmplae pattern shown below: void ovsrec_ct_zone_index_set_external_ids(const struct ovsrec_ct_zone... { // 1. alloc_fn: Storage is returned from allocation function xmalloc. // 2. var_assign: Assigning: datum = storage returned from xmalloc(24UL). struct ovsdb_datum *datum = xmalloc(sizeof(struct ovsdb_datum)); // 3. Condition external_ids, taking false branch. if (external_ids) { ... } else { // 4. noescape: Resource datum is not freed or pointed-to in ovsdb_datum_init_empty. ovsdb_datum_init_empty(datum); } // 5. noescape: Resource datum is not freed or pointed-to in ovsdb_idl_index_write. ovsdb_idl_index_write(CONST_CAST(struct ovsdb_idl_row *, &row->header_), &ovsrec_ct_zone_columns[OVSREC_CT_ZONE_COL_EXTERNAL_IDS], datum, &ovsrec_table_classes[OVSREC_TABLE_CT_ZONE]); // CID 1420856 (#1 of 1): Resource leak (RESOURCE_LEAK) // 6. leaked_storage: Variable datum going out of scope leaks the storage it points to. Fix it by freeing the datum. Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: William Tu <u9012063@gmail.com>
Diffstat (limited to 'ovsdb')
-rwxr-xr-xovsdb/ovsdb-idlc.in1
1 files changed, 1 insertions, 0 deletions
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 1d385e15c..698fe25f3 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -1306,6 +1306,7 @@ struct %(s)s *
&%(s)s_columns[%(S)s_COL_%(C)s],
datum,
&%(p)stable_classes[%(P)sTABLE_%(T)s]);
+ free(datum);
}
""" % {'t': tableName,
'p': prefix,