Clang's static analyzer will complain about a null pointer dereference because dumps can be set to null and then there is a loop where it could have been written to.
Instead, return early from the netdev_ports_flow_dump_create function if dumps is NULL. Signed-off-by: Mike Pattrick <[email protected]> --- lib/netdev-offload.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 931d634e1..02b1cf203 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -638,7 +638,14 @@ netdev_ports_flow_dump_create(const char *dpif_type, int *ports, bool terse) } } - dumps = count ? xzalloc(sizeof *dumps * count) : NULL; + if (count == 0) { + *ports = 0; + ovs_rwlock_unlock(&port_to_netdev_rwlock); + + return NULL; + } + + dumps = xzalloc(sizeof *dumps * count); HMAP_FOR_EACH (data, portno_node, &port_to_netdev) { if (netdev_get_dpif_type(data->netdev) == dpif_type) { -- 2.39.3 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
