buglet in radix_tree_tag_set
PATCH 1/1 buglet in radix_tree_tag_set
From: Peter Zijlstra <[email protected]>
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 <[email protected]>
Acked-by Nick Piggin <[email protected]>
lib/radix-tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/radix-tree.c +1 -2
@@ -365,8 +365,7 @@ void *radix_tree_tag_set(struct radix_trstruct radix_tree_node *slot; height = root->height; -if (index >radix_tree_maxindex (height)) -return NULL ; +BUG_ON (index >radix_tree_maxindex (height)) shift = (height - 1) * RADIX_TREE_MAP_SHIFT; slot = root->rnode;