From: Peter Zijlstra Date: Fri, 23 Jun 2006 09:03:25 +0000 (-0700) Subject: [PATCH] buglet in radix_tree_tag_set X-Git-Tag: v2.6.18-rc1~1081^2~187 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c91c3648c620003cb7b21b8858f36cd6132e168;p=linux-2.6 [PATCH] buglet in radix_tree_tag_set 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 Acked-by: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 7cbdada510..b32efae768 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -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;