[ovs-dev] [PATCH ovn 3/3 v2] ovn-nbd: Fix unsafe HMAP_FOR_EACH_WITH_HASH usage.
Russell Bryant
rbryant at redhat.com
Tue Apr 7 14:07:47 UTC 2015
The previous code assumed that hash_node would be NULL when the loop
terminated without a match. That's not the case, so track the match a
little differently.
Signed-off-by: Russell Bryant <rbryant at redhat.com>
---
ovn/ovn-nbd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ovn/ovn-nbd.c b/ovn/ovn-nbd.c
index 5eb1ee7..715b1bf 100644
--- a/ovn/ovn-nbd.c
+++ b/ovn/ovn-nbd.c
@@ -151,19 +151,20 @@ set_bindings(struct nbd_context *ctx)
}
NBREC_LOGICAL_PORT_FOR_EACH(lport, ctx->ovnnb_idl) {
+ binding = NULL;
HMAP_FOR_EACH_WITH_HASH(hash_node, node,
hash_string(lport->name, 0), &bindings_hmap) {
if (!strcmp(lport->name, hash_node->binding->logical_port)) {
+ binding = hash_node->binding;
break;
}
}
- if (hash_node) {
+ if (binding) {
/* We found an existing binding for this logical port. Update its
* contents. Right now the only thing we expect that could change
* is the list of MAC addresses. */
- binding = hash_node->binding;
hmap_remove(&bindings_hmap, &hash_node->node);
free(hash_node);
hash_node = NULL;
--
2.1.0
More information about the dev
mailing list