We only may set mid_split in the else clause, let's move the check in it. 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2a00441130ee..f5606b4d0dba 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2381,10 +2381,11 @@ static inline unsigned char mas_mab_to_node(struct ma_state *mas, } else { split = mab_calc_split(mas, b_node, mid_split); *right = mas_new_ma_node(mas, b_node); + + if (*mid_split) + *middle = mas_new_ma_node(mas, b_node); } - if (*mid_split) - *middle = mas_new_ma_node(mas, b_node); return split; -- 2.34.1