summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2015-04-14 21:52:54 -0400
committerBen Pfaff <blp@nicira.com>2015-04-16 10:57:57 -0700
commit1d4e6b55b50ce8455ff94593f18ef84a25a24680 (patch)
tree80285047fde47d0b4c14b96380eea9320deaaf60
parentcf1486e00425999e7244656047c1b23ef6fc7708 (diff)
downloadopenvswitch-1d4e6b55b50ce8455ff94593f18ef84a25a24680.tar.gz
ovn-nbd: Fix unsafe HMAP_FOR_EACH_WITH_HASH usage.
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@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--ovn/ovn-nbd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ovn/ovn-nbd.c b/ovn/ovn-nbd.c
index 1571a0b56..27e90c60d 100644
--- a/ovn/ovn-nbd.c
+++ b/ovn/ovn-nbd.c
@@ -152,19 +152,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;