All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo()
@ 2022-03-05 18:13 trix
  2022-03-07  7:16 ` Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: trix @ 2022-03-05 18:13 UTC (permalink / raw)
  To: davem, kuba, nathan, ndesaulniers, idosch, petrm, edumazet,
	avagin, yajun.deng, johannes.berg, cong.wang
  Cc: netdev, linux-kernel, llvm, Tom Rix

From: Tom Rix <trix@redhat.com>

The clang static analyzer reports this issue
rtnetlink.c:5481:2: warning: Undefined or garbage
  value returned to caller
  return err;
  ^~~~~~~~~~

There is a function level err variable, in the
list_for_each_entry_rcu block there is a shadow
err.  Remove the shadow.

In the same block, the call to nla_nest_start_noflag()
can fail without setting an err.  Set the err
to -EMSGSIZE.

Fixes: 216e690631f5 ("net: rtnetlink: rtnl_fill_statsinfo(): Permit non-EMSGSIZE error returns")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 net/core/rtnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a66b6761b88b1..a759f9e0a8476 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -5440,12 +5440,12 @@ static int rtnl_fill_statsinfo(struct sk_buff *skb, struct net_device *dev,
 		list_for_each_entry_rcu(af_ops, &rtnl_af_ops, list) {
 			if (af_ops->fill_stats_af) {
 				struct nlattr *af;
-				int err;
 
 				af = nla_nest_start_noflag(skb,
 							   af_ops->family);
 				if (!af) {
 					rcu_read_unlock();
+					err = -EMSGSIZE;
 					goto nla_put_failure;
 				}
 				err = af_ops->fill_stats_af(skb, dev);
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo()
  2022-03-05 18:13 [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo() trix
@ 2022-03-07  7:16 ` Ido Schimmel
  2022-03-07  9:43 ` Petr Machata
  2022-03-07 12:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2022-03-07  7:16 UTC (permalink / raw)
  To: trix
  Cc: davem, kuba, nathan, ndesaulniers, idosch, petrm, edumazet,
	avagin, yajun.deng, johannes.berg, cong.wang, netdev,
	linux-kernel, llvm

On Sat, Mar 05, 2022 at 10:13:46AM -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> The clang static analyzer reports this issue
> rtnetlink.c:5481:2: warning: Undefined or garbage
>   value returned to caller
>   return err;
>   ^~~~~~~~~~
> 
> There is a function level err variable, in the
> list_for_each_entry_rcu block there is a shadow
> err.  Remove the shadow.
> 
> In the same block, the call to nla_nest_start_noflag()
> can fail without setting an err.  Set the err
> to -EMSGSIZE.
> 
> Fixes: 216e690631f5 ("net: rtnetlink: rtnl_fill_statsinfo(): Permit non-EMSGSIZE error returns")
> Signed-off-by: Tom Rix <trix@redhat.com>

For net-next:

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo()
  2022-03-05 18:13 [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo() trix
  2022-03-07  7:16 ` Ido Schimmel
@ 2022-03-07  9:43 ` Petr Machata
  2022-03-07 12:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Petr Machata @ 2022-03-07  9:43 UTC (permalink / raw)
  To: trix
  Cc: davem, kuba, nathan, ndesaulniers, idosch, petrm, edumazet,
	avagin, yajun.deng, johannes.berg, cong.wang, netdev,
	linux-kernel, llvm


trix@redhat.com writes:

> From: Tom Rix <trix@redhat.com>
>
> The clang static analyzer reports this issue
> rtnetlink.c:5481:2: warning: Undefined or garbage
>   value returned to caller
>   return err;
>   ^~~~~~~~~~
>
> There is a function level err variable, in the
> list_for_each_entry_rcu block there is a shadow
> err.  Remove the shadow.
>
> In the same block, the call to nla_nest_start_noflag()
> can fail without setting an err.  Set the err
> to -EMSGSIZE.
>
> Fixes: 216e690631f5 ("net: rtnetlink: rtnl_fill_statsinfo(): Permit non-EMSGSIZE error returns")
> Signed-off-by: Tom Rix <trix@redhat.com>

Reviewed-by: Petr Machata <petrm@nvidia.com>

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo()
  2022-03-05 18:13 [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo() trix
  2022-03-07  7:16 ` Ido Schimmel
  2022-03-07  9:43 ` Petr Machata
@ 2022-03-07 12:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-07 12:30 UTC (permalink / raw)
  To: Tom Rix
  Cc: davem, kuba, nathan, ndesaulniers, idosch, petrm, edumazet,
	avagin, yajun.deng, johannes.berg, cong.wang, netdev,
	linux-kernel, llvm

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Sat,  5 Mar 2022 10:13:46 -0800 you wrote:
> From: Tom Rix <trix@redhat.com>
> 
> The clang static analyzer reports this issue
> rtnetlink.c:5481:2: warning: Undefined or garbage
>   value returned to caller
>   return err;
>   ^~~~~~~~~~
> 
> [...]

Here is the summary with links:
  - net: rtnetlink: fix error handling in rtnl_fill_statsinfo()
    https://git.kernel.org/netdev/net-next/c/57d29a2935c9

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] 4+ messages in thread

end of thread, other threads:[~2022-03-07 12:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 18:13 [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo() trix
2022-03-07  7:16 ` Ido Schimmel
2022-03-07  9:43 ` Petr Machata
2022-03-07 12:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.