fib_trie: handle empty tree
authorStephen Hemminger <shemminger@vyatta.com>
Tue, 12 Feb 2008 05:12:49 +0000 (21:12 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Feb 2008 01:53:30 +0000 (17:53 -0800)
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

index f5fba3f..2d89527 100644 (file)
@@ -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;
 }