Just like mas_wr_extend_null(), only when content is not NULL, we may have a NULL slot ahead. So we can wrap it in an else. Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> CC: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> CC: Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx> CC: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> --- lib/maple_tree.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 7efb1520f9bd..98692704d773 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3568,18 +3568,20 @@ static inline void mas_extend_spanning_null(struct ma_wr_state *l_wr_mas, unsigned char l_slot; l_slot = l_mas->offset; - if (!l_wr_mas->content) + if (!l_wr_mas->content) { + /* If this one is null, the next and prev are not */ l_mas->index = l_wr_mas->r_min; + } else { + if ((l_mas->index == l_wr_mas->r_min) && + (l_slot && + !mas_slot_locked(l_mas, l_wr_mas->slots, l_slot - 1))) { + if (l_slot > 1) + l_mas->index = l_wr_mas->pivots[l_slot - 2] + 1; + else + l_mas->index = l_mas->min; - if ((l_mas->index == l_wr_mas->r_min) && - (l_slot && - !mas_slot_locked(l_mas, l_wr_mas->slots, l_slot - 1))) { - if (l_slot > 1) - l_mas->index = l_wr_mas->pivots[l_slot - 2] + 1; - else - l_mas->index = l_mas->min; - - l_mas->offset = l_slot - 1; + l_mas->offset = l_slot - 1; + } } if (!r_wr_mas->content) { -- 2.34.1