]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] buglet in radix_tree_tag_set
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Fri, 23 Jun 2006 09:03:25 +0000 (02:03 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 23 Jun 2006 14:42:49 +0000 (07:42 -0700)
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>
lib/radix-tree.c

index 7cbdada51049738f4bd105f88f1ca0956daa390f..b32efae7688e316e8825df6fd76a316a2c6f18bf 100644 (file)
@@ -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;