summaryrefslogtreecommitdiff
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-02-11 21:12:49 -0800
committerDavid S. Miller <davem@davemloft.net>2008-02-12 17:53:30 -0800
commitec28cf738d899e9d0652108e1986101771aacb2e (patch)
treee848267fc6f9946075a0440be8b0a8ac6ef0c58a /net/ipv4/fib_trie.c
parente4f8b5d4edc1edb0709531bd1a342655d5e8b98e (diff)
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>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f5fba3f71c06..2d895274b7f8 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;
}