Re: [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo()

From: Petr Machata
Date: Mon Mar 07 2022 - 05:11:39 EST



trix@xxxxxxxxxx writes:

> From: Tom Rix <trix@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>

Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>

Thanks!