]> git.baikalelectronics.ru Git - kernel.git/commit
net: rtnetlink: fix error handling in rtnl_fill_statsinfo()
authorTom Rix <trix@redhat.com>
Sat, 5 Mar 2022 18:13:46 +0000 (10:13 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Mar 2022 12:26:53 +0000 (12:26 +0000)
commita7be8089109126c8e6b7ff40c1aef7e0737c600d
tree14dd865f56e08c9e7d6aa5ea9c15d841c004cb18
parent58a8d7aae926c26f74cc1340032286e461fbae78
net: rtnetlink: fix error handling in rtnl_fill_statsinfo()

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: 90f1748365a4 ("net: rtnetlink: rtnl_fill_statsinfo(): Permit non-EMSGSIZE error returns")
Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c