Browse Source

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>
Stephen Hemminger 17 years ago
parent
commit
ec28cf738d
1 changed files with 2 additions and 4 deletions
  1. 2 4
      net/ipv4/fib_trie.c

+ 2 - 4
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);
 	struct leaf *l = trie_firstleaf(t);
 
 
-	while (index-- > 0) {
+	while (l && index-- > 0)
 		l = trie_nextleaf(l);
 		l = trie_nextleaf(l);
-		if (!l)
-			break;
-	}
+
 	return l;
 	return l;
 }
 }