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.
Cc: Peter Zijlstra <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Michel Lespinasse <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Signed-off-by: Lai Jiangshan <[email protected]> --- 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 b012bd95eabf..09a3c05d1c5b 100644 --- a/include/linux/rbtree_latch.h +++ b/include/linux/rbtree_latch.h @@ -208,7 +208,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

