From 7aaf659c3689982222a7c2a1a6e5c49ef64a2b39 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 14 Jan 2020 12:34:47 -0500 Subject: [PATCH] maple_tree: fix setting parent during split. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 19946237dd87..7cb11bb4521c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2155,8 +2155,8 @@ static inline int mas_split(struct ma_state *mas, unsigned char slot, left.node = mt_mk_node(ma_mnode_ptr(mas_next_alloc(mas)), type); right.node = mt_mk_node(ma_mnode_ptr(mas_next_alloc(mas)), type); - mte_set_parent(left.node, new_parent, p_slot); - mte_set_parent(right.node, new_parent, p_slot+1); + mte_set_parent(left.node, mte_to_node(new_parent), p_slot); + mte_set_parent(right.node, mte_to_node(new_parent), p_slot+1); // split the data into left & right and do the insert. split = mas_ma_cp(mas, p_slot, &left, &right, NULL, type, 0, entry_cnt, entry, 0); @@ -4094,6 +4094,8 @@ skip_right: error: if (new_mas.tree) mte_destroy_walk(new_mas.tree->ma_root); + printk("Failed on %lu-%lu\n", mas->index, mas->last); + mt_dump(mas->tree); BUG_ON(1); return 0; } @@ -4645,15 +4647,15 @@ void *mtree_load(struct maple_tree *mt, unsigned long index) } EXPORT_SYMBOL(mtree_load); -int mtree_store_range(struct maple_tree *mt, unsigned long first, +int mtree_store_range(struct maple_tree *mt, unsigned long index, unsigned long last, void *entry, gfp_t gfp) { - MA_STATE(mas, mt, first, last); + MA_STATE(mas, mt, index, last); if (WARN_ON_ONCE(mt_is_advanced(entry))) return -EINVAL; - if (first > last) + if (index > last) return -EINVAL; mas_lock(&mas); -- 2.50.1