Coverity reported a possible null dereference of datum->values
when handling value-type weak references in find_and_add_weak_refs().

In practice, datum->values must be non-NULL for value-type weak references.
Adding ovs_assert(datum->values) documents this invariant and ensures that
we catch any unexpected misuse.

No change to runtime behavior in production builds; this only improves
safety and satisfies static analysis.

Signed-off-by: Eelco Chaudron <echau...@redhat.com>

v2: Move the assert out of the loop + !datum->n check.
---
 ovsdb/transaction.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c
index 39650d3b3..d16f4daa3 100644
--- a/ovsdb/transaction.c
+++ b/ovsdb/transaction.c
@@ -646,6 +646,7 @@ find_and_add_weak_refs(const struct ovsdb_row *src,
     }
 
     if (ovsdb_base_type_is_weak_ref(&column->type.value)) {
+        ovs_assert(!datum->n || datum->values);
         for (i = 0; i < datum->n; i++) {
             find_and_add_weak_ref(src, &datum->keys[i], &datum->values[i],
                                   column, false, ref_list, not_found, zero);
-- 
2.50.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to