lkml.org 
[lkml]   [2008]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 05/22] lib/idr.c: Fix bug introduced by RCU fix
    2.6.27-stable review patch.  If anyone has any objections, please let us know.

    ------------------

    From: Manfred Spraul <manfred@colorfullife.com>

    commit 711a49a07f84f914aac26a52143f6e7526571143 upstream.

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---
    lib/idr.c | 8 +++++++-
    1 file changed, 7 insertions(+), 1 deletion(-)

    --- a/lib/idr.c
    +++ b/lib/idr.c
    @@ -220,8 +220,14 @@ build_up:
    */
    while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) {
    layers++;
    - if (!p->count)
    + if (!p->count) {
    + /* special case: if the tree is currently empty,
    + * then we grow the tree by moving the top node
    + * upwards.
    + */
    + p->layer++;
    continue;
    + }
    if (!(new = get_from_free_list(idp))) {
    /*
    * The allocation failed. If we built part of


    \
     
     \ /
      Last update: 2008-12-17 01:09    [W:0.024 / U:30.636 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site