[PATCH] maple_tree: Fix sparse reported issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When building with C=1, the maple tree had some rcu type mismatch &
locking mismatches in the destroy functions.  There were cosmetic only
since this happens after the nodes are removed from the tree.

Fixes: f8acc5e9581e (Maple Tree: add new data structure)
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
---
 lib/maple_tree.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 79e07c7dc323..9dc4ffff18d0 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2319,7 +2319,7 @@ static inline void mast_topiary(struct maple_subtree_state *mast)
 	MA_WR_STATE(wr_mas, mast->orig_l, NULL);
 	unsigned char r_start, r_end;
 	unsigned char l_start, l_end;
-	void **l_slots, **r_slots;
+	void __rcu **l_slots, **r_slots;
 
 	wr_mas.type = mte_node_type(mast->orig_l->node);
 	mast->orig_l->index = mast->orig_l->last;
@@ -5461,6 +5461,7 @@ static void mt_free_walk(struct rcu_head *head)
 	mt_free_bulk(node->slot_len, slots);
 
 start_slots_free:
+	mas_unlock(&mas);
 free_leaf:
 	mt_free_rcu(&node->rcu);
 }
@@ -5513,6 +5514,7 @@ static void mt_destroy_walk(struct maple_enode *enode, unsigned char ma_flags,
 	do {
 		enum maple_type type;
 		unsigned char offset;
+		struct maple_enode *parent, *tmp;
 
 		node->slot_len = mas_dead_leaves(&mas, slots);
 		if (free)
@@ -5524,13 +5526,17 @@ static void mt_destroy_walk(struct maple_enode *enode, unsigned char ma_flags,
 
 		type = mte_node_type(mas.node);
 		slots = ma_slots(mte_to_node(mas.node), type);
-		if ((offset < mt_slots[type]) && mte_node_type(slots[offset]) &&
-		    mte_to_node(slots[offset])) {
-			struct maple_enode *parent = mas.node;
+		if (offset >= mt_slots[type])
+			goto next;
 
-			mas.node = mas_slot_locked(&mas, slots, offset);
+		tmp = mas_slot_locked(&mas, slots, offset);
+		if (mte_node_type(tmp) && mte_to_node(tmp)) {
+
+			parent = mas.node;
+			mas.node = tmp;
 			slots = mas_destroy_descend(&mas, parent, offset);
 		}
+next:
 		node = mas_mn(&mas);
 	} while (start != mas.node);
 
-- 
2.35.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux