aboutsummaryrefslogtreecommitdiffstats
path: root/lib/idr.c
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2008-12-10 12:17:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-10 16:34:33 -0500
commit711a49a07f84f914aac26a52143f6e7526571143 (patch)
tree3ca4f774f868c1884bc6dc416ea68aa7b8666ef7 /lib/idr.c
parentc7f8d6f6b5d121e5f7408119661ca29fc4661c10 (diff)
lib/idr.c: Fix bug introduced by RCU fix
The last patch to lib/idr.c caused a bug if idr_get_new_above() was called on an empty idr. Usually, nodes stay on the same layer. New layers are added to the top of the tree. The exception is idr_get_new_above() on an empty tree: In this case, the new root node is first added on layer 0, then moved upwards. p->layer was not updated. As usual: You shall never rely on the source code comments, they will only mislead you. Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/idr.c')
-rw-r--r--lib/idr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/idr.c b/lib/idr.c
index 7a785a0c2ea0..1c4f9281f412 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -220,8 +220,14 @@ build_up:
220 */ 220 */
221 while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) { 221 while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) {
222 layers++; 222 layers++;
223 if (!p->count) 223 if (!p->count) {
224 /* special case: if the tree is currently empty,
225 * then we grow the tree by moving the top node
226 * upwards.
227 */
228 p->layer++;
224 continue; 229 continue;
230 }
225 if (!(new = get_from_free_list(idp))) { 231 if (!(new = get_from_free_list(idp))) {
226 /* 232 /*
227 * The allocation failed. If we built part of 233 * The allocation failed. If we built part of