fib_trie: handle empty tree

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Friday, February 15, 2008 - 6:00 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ec28cf...
Commit:     ec28cf738d899e9d0652108e1986101771aacb2e
Parent:     e4f8b5d4edc1edb0709531bd1a342655d5e8b98e
Author:     Stephen Hemminger <shemminger@vyatta.com>
AuthorDate: Mon Feb 11 21:12:49 2008 -0800
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Tue Feb 12 17:53:30 2008 -0800

    fib_trie: handle empty tree
    
    This fixes possible problems when trie_firstleaf() returns NULL
    to trie_leafindex().
    
    Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv4/fib_trie.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f5fba3f..2d89527 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1762,11 +1762,9 @@ static struct leaf *trie_leafindex(struct trie *t, int index)
 {
 	struct leaf *l = trie_firstleaf(t);
 
-	while (index-- > 0) {
+	while (l && index-- > 0)
 		l = trie_nextleaf(l);
-		if (!l)
-			break;
-	}
+
 	return l;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
fib_trie: handle empty tree, Linux Kernel Mailing List..., (Fri Feb 15, 6:00 pm)