latch_tree_find() should be protected by caller via RCU or so. When it find a node in an attempt, the node must be a valid one in RCU's point's of view even the tree is (being) updated with a new node with the same key which is entirely subject to timing anyway.
Cc: Paul E. McKenney <paul...@kernel.org> Cc: Oleg Nesterov <o...@redhat.com> Cc: Michel Lespinasse <wal...@google.com> Cc: Andrea Arcangeli <aarca...@redhat.com> Cc: Rik van Riel <r...@redhat.com> Cc: Mathieu Desnoyers <mathieu.desnoy...@efficios.com> Acked-by: Peter Zijlstra (Intel) <pet...@infradead.org> Signed-off-by: Lai Jiangshan <la...@linux.alibaba.com> --- include/linux/rbtree_latch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/rbtree_latch.h b/include/linux/rbtree_latch.h index 638942f53c0a..affc4b026d9b 100644 --- a/include/linux/rbtree_latch.h +++ b/include/linux/rbtree_latch.h @@ -245,7 +245,7 @@ latch_tree_find(void *key, struct latch_tree_root *root, do { seq = raw_read_seqcount_latch(&root->seq); node = __lt_find(key, root, seq & 1, ops->comp); - } while (read_seqcount_retry(&root->seq, seq)); + } while (!node && read_seqcount_retry(&root->seq, seq)); return node; } -- 2.20.1