On Mon 06 Sep 2021 at 19:39, Linus Torvalds torvalds@linux-foundation.org wrote:
On Mon, Sep 6, 2021 at 2:11 AM Naresh Kamboju naresh.kamboju@linaro.org wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:157:11: error: variable 'err' is used uninitialized whenever 'if' condition is false
That compiler warning (now error) seems to be entirely valid.
I agree, this is a real issue. It had been reported before and my fix for it was submitted by Saeed last week but wasn't accepted since it was part of larger series that also included features and net-next had already been closed by that time. As far as I understand it is pending submission to net as part of series of bug fixes. Sorry for the delay.
That's a
if (..) else if (..)
and if neither are valid then the code will return an uninitialized 'err'.
It's possible the two conditionals are guaranteed to cover all cases, but as the compiler says, in that case the "if" in the else clause is pointless and should be removed.
But it does look like 'ret' should probably just be initialized to 0.
Yep, this if exactly what I did in my patch "net/mlx5: Bridge, fix uninitialized variable usage".
Linus