Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Manfred Spraul and committed by
Linus Torvalds
711a49a0 c7f8d6f6

+7 -1
+7 -1
lib/idr.c
··· 220 220 */ 221 221 while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) { 222 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 229 continue; 230 + } 225 231 if (!(new = get_from_free_list(idp))) { 226 232 /* 227 233 * The allocation failed. If we built part of