net: fib_notifier: don't return positive values on fib registration
Subsystems (3)
PATCH 1/1 net: fib_notifier: don't return positive values on fib registration
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().
--- net/ipv6/ip6_fib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv6/ip6_fib.c +3 -2
@@ -499,7 +499,7 @@ 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; } }
@@ -507,7 +507,8 @@ int fib6_tables_dump(struct net *net, struct notifier_block *nb, 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)
Signature · 1 line
2.29.2
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Thu, 11 Feb 2021 12:07:59 +0200 you wrote:
The function
fib6_walk_continue()cannot return a positive value when called fromregister_fib_notifier(), but ignoring causes static analyzer to generate warnings in users ofregister_fib_notifier()that try to convert returned error code to pointer withERR_PTR(). Handle such case by explicitly checking for positive error values and converting them to-EINVALinfib6_tables_dump().[...]
Here is the summary with links:
- [net-next] net: fib_notifier: don't return positive values on fib registration
https://git.kernel.org/netdev/net-next/c/6f1995523a0f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html