Commit 48a3a8cd authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Linus Torvalds

[PATCH] 64 bit bug in radix-tree lookup.

The radix tree functions __lookup and __lookup_tag uses (1 << shift) in
their index calculations.  On 64 bit systems the shift can be bigger than
32.  The shift of an integer by more than 32 bits evaluates to zero which
causes the lookup to fail.
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 03071ffe
......@@ -485,8 +485,8 @@ __lookup(struct radix_tree_root *root, void **results, unsigned long index,
for ( ; i < RADIX_TREE_MAP_SIZE; i++) {
if (slot->slots[i] != NULL)
break;
index &= ~((1 << shift) - 1);
index += 1 << shift;
index &= ~((1UL << shift) - 1);
index += 1UL << shift;
if (index == 0)
goto out; /* 32-bit wraparound */
}
......@@ -575,8 +575,8 @@ __lookup_tag(struct radix_tree_root *root, void **results, unsigned long index,
BUG_ON(slot->slots[i] == NULL);
break;
}
index &= ~((1 << shift) - 1);
index += 1 << shift;
index &= ~((1UL << shift) - 1);
index += 1UL << shift;
if (index == 0)
goto out; /* 32-bit wraparound */
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment