]> err.no Git - linux-2.6/commitdiff
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 f5fba3f71c06e09283a29d48f2719bc9ad1be15b..2d895274b7f82f959132dd39053acf5550180439 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;
 }