diff options
Diffstat (limited to 'lib/maple_tree.c')
| -rw-r--r-- | lib/maple_tree.c | 22 | 
1 files changed, 11 insertions, 11 deletions
| diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 26e2045d3cda..5a976393c9ae 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -670,12 +670,13 @@ static inline unsigned long mte_pivot(const struct maple_enode *mn,  				 unsigned char piv)  {  	struct maple_node *node = mte_to_node(mn); +	enum maple_type type = mte_node_type(mn); -	if (piv >= mt_pivots[piv]) { +	if (piv >= mt_pivots[type]) {  		WARN_ON(1);  		return 0;  	} -	switch (mte_node_type(mn)) { +	switch (type) {  	case maple_arange_64:  		return node->ma64.pivot[piv];  	case maple_range_64: @@ -4887,7 +4888,7 @@ static bool mas_rev_awalk(struct ma_state *mas, unsigned long size)  	unsigned long *pivots, *gaps;  	void __rcu **slots;  	unsigned long gap = 0; -	unsigned long max, min, index; +	unsigned long max, min;  	unsigned char offset;  	if (unlikely(mas_is_err(mas))) @@ -4909,8 +4910,7 @@ static bool mas_rev_awalk(struct ma_state *mas, unsigned long size)  		min = mas_safe_min(mas, pivots, --offset);  	max = mas_safe_pivot(mas, pivots, offset, type); -	index = mas->index; -	while (index <= max) { +	while (mas->index <= max) {  		gap = 0;  		if (gaps)  			gap = gaps[offset]; @@ -4941,10 +4941,8 @@ static bool mas_rev_awalk(struct ma_state *mas, unsigned long size)  		min = mas_safe_min(mas, pivots, offset);  	} -	if (unlikely(index > max)) { -		mas_set_err(mas, -EBUSY); -		return false; -	} +	if (unlikely((mas->index > max) || (size - 1 > max - mas->index))) +		goto no_space;  	if (unlikely(ma_is_leaf(type))) {  		mas->offset = offset; @@ -4961,9 +4959,11 @@ static bool mas_rev_awalk(struct ma_state *mas, unsigned long size)  	return false;  ascend: -	if (mte_is_root(mas->node)) -		mas_set_err(mas, -EBUSY); +	if (!mte_is_root(mas->node)) +		return false; +no_space: +	mas_set_err(mas, -EBUSY);  	return false;  } |