X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Frbtree.c;h=48499c2d88ccf16d65c8891e3fc5a23e8cdf283a;hb=3ac7fe5a4aab409bd5674d0b070bce97f9d20872;hp=1e55ba1c2edfac510c41c87e47e7849f99a5f3b3;hpb=8542e5893c2b10b4f6c80149e7dc3fdd2dc38bc6;p=linux-2.6 diff --git a/lib/rbtree.c b/lib/rbtree.c index 1e55ba1c2e..48499c2d88 100644 --- a/lib/rbtree.c +++ b/lib/rbtree.c @@ -322,6 +322,9 @@ struct rb_node *rb_next(struct rb_node *node) { struct rb_node *parent; + if (rb_parent(node) == node) + return NULL; + /* If we have a right-hand child, go down and then left as far as we can. */ if (node->rb_right) { @@ -348,6 +351,9 @@ struct rb_node *rb_prev(struct rb_node *node) { struct rb_node *parent; + if (rb_parent(node) == node) + return NULL; + /* If we have a left-hand child, go down and then right as far as we can. */ if (node->rb_left) {