* [PATCH net-next] net: fib_notifier: don't return positive values on fib registration
@ 2021-02-11 10:07 Vlad Buslov
2021-02-11 22:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Vlad Buslov @ 2021-02-11 10:07 UTC (permalink / raw)
To: davem, kuba; +Cc: netdev, Vlad Buslov, Dan Carpenter, Ido Schimmel
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>
---
net/ipv6/ip6_fib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index f43e27555725..ef9d022e693f 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -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)
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: fib_notifier: don't return positive values on fib registration
2021-02-11 10:07 [PATCH net-next] net: fib_notifier: don't return positive values on fib registration Vlad Buslov
@ 2021-02-11 22:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-11 22:50 UTC (permalink / raw)
To: Vlad Buslov; +Cc: davem, kuba, netdev, dan.carpenter, idosch
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Thu, 11 Feb 2021 12:07:59 +0200 you wrote:
> 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().
>
> [...]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-11 22:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-11 10:07 [PATCH net-next] net: fib_notifier: don't return positive values on fib registration Vlad Buslov
2021-02-11 22:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).