Skip to content

Commit ab6ef70

Browse files
RichardWeiYangakpm00
authored andcommitted
maple_tree: should get pivots boundary by type
We should get pivots boundary by type. Fixes a potential overindexing of mt_pivots[]. Link: https://lkml.kernel.org/r/[email protected] Fixes: 54a611b ("Maple Tree: add new data structure") Signed-off-by: Wei Yang <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 889a904 commit ab6ef70

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/maple_tree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,13 @@ static inline unsigned long mte_pivot(const struct maple_enode *mn,
670670
unsigned char piv)
671671
{
672672
struct maple_node *node = mte_to_node(mn);
673+
enum maple_type type = mte_node_type(mn);
673674

674-
if (piv >= mt_pivots[piv]) {
675+
if (piv >= mt_pivots[type]) {
675676
WARN_ON(1);
676677
return 0;
677678
}
678-
switch (mte_node_type(mn)) {
679+
switch (type) {
679680
case maple_arange_64:
680681
return node->ma64.pivot[piv];
681682
case maple_range_64:

0 commit comments

Comments
 (0)