diff options
author | Matthew Wilcox <willy@linux.intel.com> | 2016-05-20 20:02:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 20:58:30 -0400 |
commit | 8a14f4d8328cc8615f8a5487c4173f36a8314796 (patch) | |
tree | df71c04e61341c3d21acc8e2786af46759aad703 /lib | |
parent | 0fc9b8ca2b1df4948e9516697b1cf12f030968bd (diff) |
radix-tree: fix radix_tree_create for sibling entries
If the radix tree user attempted to insert a colliding entry with an
existing multiorder entry, then radix_tree_create() could encounter a
sibling entry when walking down the tree to look for a slot. Use
radix_tree_descend() to fix the problem, and add a test-case to make
sure the problem doesn't come back in future.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com>
Cc: Jan Kara <jack@suse.com>
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/radix-tree.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index b1ca74489bc2..9b5d8a963897 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -548,9 +548,9 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index, | |||
548 | /* Go a level down */ | 548 | /* Go a level down */ |
549 | height--; | 549 | height--; |
550 | shift -= RADIX_TREE_MAP_SHIFT; | 550 | shift -= RADIX_TREE_MAP_SHIFT; |
551 | offset = (index >> shift) & RADIX_TREE_MAP_MASK; | ||
552 | node = indirect_to_ptr(slot); | 551 | node = indirect_to_ptr(slot); |
553 | slot = node->slots[offset]; | 552 | offset = (index >> shift) & RADIX_TREE_MAP_MASK; |
553 | offset = radix_tree_descend(node, &slot, offset); | ||
554 | } | 554 | } |
555 | 555 | ||
556 | #ifdef CONFIG_RADIX_TREE_MULTIORDER | 556 | #ifdef CONFIG_RADIX_TREE_MULTIORDER |