lib/radix-tree.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 1b7bf7314141..210709b07759 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -78,18 +78,20 @@ static inline void *node_to_entry(void *ptr) #ifdef CONFIG_RADIX_TREE_MULTIORDER /* Sibling slots point directly to another slot in the same node */ -static inline bool is_sibling_entry(struct radix_tree_node *parent, void *node) +static inline void **get_sibling_entry(struct radix_tree_node *parent, void *node) { - void **ptr = node; - return (parent->slots <= ptr) && - (ptr < parent->slots + RADIX_TREE_MAP_SIZE); + void **ptr = (void **) entry_to_node(node); + if ((parent->slots <= ptr) && (ptr < parent->slots + RADIX_TREE_MAP_SIZE)) + return ptr; + return NULL; } #else -static inline bool is_sibling_entry(struct radix_tree_node *parent, void *node) +static inline void **get_sibling_entry(struct radix_tree_node *parent, void *node) { - return false; + return NULL; } #endif +#define is_sibling_entry(parent, node) (get_sibling_entry(parent,node) != NULL) static inline unsigned long get_slot_offset(struct radix_tree_node *parent, void **slot) @@ -105,10 +107,10 @@ static unsigned int radix_tree_descend(struct radix_tree_node *parent, #ifdef CONFIG_RADIX_TREE_MULTIORDER if (radix_tree_is_internal_node(entry)) { - unsigned long siboff = get_slot_offset(parent, entry); - if (siboff < RADIX_TREE_MAP_SIZE) { - offset = siboff; - entry = rcu_dereference_raw(parent->slots[offset]); + void **sibentry = get_sibling_entry(parent, entry); + if (sibentry) { + offset = get_slot_offset(parent, sibentry); + entry = rcu_dereference_raw(*sibentry); } } #endif