Skip to content

Commit

Permalink
net: fib_notifier: don't return positive values on fib registration
Browse files Browse the repository at this point in the history
The function fib6_walk_continue() cannot return a positive value when
called from register_fib_notifier(), but ignoring causes static analyzer to
generate warnings in users of register_fib_notifier() that try to convert
returned error code to pointer with ERR_PTR(). Handle such case by
explicitly checking for positive error values and converting them to
-EINVAL in fib6_tables_dump().

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Buslov authored and David S. Miller committed Feb 11, 2021
1 parent 9f1b0df commit 6f19955
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/ipv6/ip6_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,16 @@ int fib6_tables_dump(struct net *net, struct notifier_block *nb,

hlist_for_each_entry_rcu(tb, head, tb6_hlist) {
err = fib6_table_dump(net, tb, w);
if (err < 0)
if (err)
goto out;
}
}

out:
kfree(w);

return err;
/* The tree traversal function should never return a positive value. */
return err > 0 ? -EINVAL : err;
}

static int fib6_dump_node(struct fib6_walker *w)
Expand Down

0 comments on commit 6f19955

Please sign in to comment.