Skip to content

Commit

Permalink
[PATCH] buglet in radix_tree_tag_set
Browse files Browse the repository at this point in the history
The comment states: 'Setting a tag on a not-present item is a BUG.' Hence
if 'index' is larger than the maxindex; the item _cannot_ be presen; it
should also be a BUG.

Also, this allows the following statement (assume a fresh tree):

  radix_tree_tag_set(root, 16, 1);

to fail silently, but when preceded by:

  radix_tree_insert(root, 32, item);

it would BUG, because the height has been extended by the insert.

In neither case was 16 present.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Peter Zijlstra authored and Linus Torvalds committed Jun 23, 2006
1 parent 58ce1fd commit 4c91c36
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/radix-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ void *radix_tree_tag_set(struct radix_tree_root *root,
struct radix_tree_node *slot;

height = root->height;
if (index > radix_tree_maxindex(height))
return NULL;
BUG_ON(index > radix_tree_maxindex(height));

slot = root->rnode;
shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
Expand Down

0 comments on commit 4c91c36

Please sign in to comment.