Ensure that the stores to rb_left and rb_right are complete before
inserting the new node into the tree. Otherwise a concurrent reader
could see garbage in the new leaf.
Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
node->rb_parent_color = (uintptr_t)parent;
node->rb_left = node->rb_right = NULL;
- qatomic_set(rb_link, node);
+ /*
+ * Ensure that node is initialized before insertion,
+ * as viewed by a concurrent search.
+ */
+ qatomic_set_mb(rb_link, node);
}
static RBNode *rb_next(RBNode *node)