diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/radix-tree.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 53fd44d78716..48c250fe2233 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -1049,12 +1049,14 @@ radix_tree_node_ctor(struct kmem_cache *cachep, void *node) static __init unsigned long __maxindex(unsigned int height) { - unsigned int tmp = height * RADIX_TREE_MAP_SHIFT; - unsigned long index = (~0UL >> (RADIX_TREE_INDEX_BITS - tmp - 1)) >> 1; - - if (tmp >= RADIX_TREE_INDEX_BITS) - index = ~0UL; - return index; + unsigned int width = height * RADIX_TREE_MAP_SHIFT; + int shift = RADIX_TREE_INDEX_BITS - width; + + if (shift < 0) + return ~0UL; + if (shift >= BITS_PER_LONG) + return 0UL; + return ~0UL >> shift; } static __init void radix_tree_init_maxindex(void) |