Skip to content

Commit

Permalink
fib_trie: handle empty tree
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Feb 13, 2008
1 parent e4f8b5d commit ec28cf7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ec28cf7

Please sign in to comment.