maple_tree: fix potential rcu issue
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 20 Jan 2023 16:26:03 +0000 (11:26 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 22 Mar 2023 16:03:23 +0000 (12:03 -0400)
Ensure the node isn't dead after reading the node end.

Link: https://lkml.kernel.org/r/20230120162650.984577-3-Liam.Howlett@oracle.com
Cc: <Stable@vger.kernel.org>
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index fd824b065aceb4a4c87867a4a77c014e3ef5be06..1ade7748cc9b7d9dc0077b21851a95a7e22de2fc 100644 (file)
@@ -4656,13 +4656,13 @@ static inline void *mas_next_nentry(struct ma_state *mas,
        pivots = ma_pivots(node, type);
        slots = ma_slots(node, type);
        mas->index = mas_safe_min(mas, pivots, mas->offset);
+       count = ma_data_end(node, type, pivots, mas->max);
        if (ma_dead_node(node))
                return NULL;
 
        if (mas->index > max)
                return NULL;
 
-       count = ma_data_end(node, type, pivots, mas->max);
        if (mas->offset > count)
                return NULL;