diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbtree.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/rbtree.c b/lib/rbtree.c index 1e55ba1c2edf..48499c2d88cc 100644 --- a/lib/rbtree.c +++ b/lib/rbtree.c | |||
@@ -322,6 +322,9 @@ struct rb_node *rb_next(struct rb_node *node) | |||
322 | { | 322 | { |
323 | struct rb_node *parent; | 323 | struct rb_node *parent; |
324 | 324 | ||
325 | if (rb_parent(node) == node) | ||
326 | return NULL; | ||
327 | |||
325 | /* If we have a right-hand child, go down and then left as far | 328 | /* If we have a right-hand child, go down and then left as far |
326 | as we can. */ | 329 | as we can. */ |
327 | if (node->rb_right) { | 330 | if (node->rb_right) { |
@@ -348,6 +351,9 @@ struct rb_node *rb_prev(struct rb_node *node) | |||
348 | { | 351 | { |
349 | struct rb_node *parent; | 352 | struct rb_node *parent; |
350 | 353 | ||
354 | if (rb_parent(node) == node) | ||
355 | return NULL; | ||
356 | |||
351 | /* If we have a left-hand child, go down and then right as far | 357 | /* If we have a left-hand child, go down and then right as far |
352 | as we can. */ | 358 | as we can. */ |
353 | if (node->rb_left) { | 359 | if (node->rb_left) { |