All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlad Buslov <vladbu@nvidia.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Saeed Mahameed <saeedm@nvidia.com>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>,
	open list <linux-kernel@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	<lkft-triage@lists.linaro.org>, Netdev <netdev@vger.kernel.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: bridge.c:157:11: error: variable 'err' is used uninitialized whenever 'if' condition is false
Date: Mon, 6 Sep 2021 20:35:37 +0300	[thread overview]
Message-ID: <ygnhk0jtwqs6.fsf@nvidia.com> (raw)
In-Reply-To: <CAHk-=wjJ-nr87H_o8y=Gx=DJYPTkxtXz_c=pj_GNdL+XRUMNgQ@mail.gmail.com>

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


  reply	other threads:[~2021-09-06 17:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06  9:10 bridge.c:157:11: error: variable 'err' is used uninitialized whenever 'if' condition is false Naresh Kamboju
2021-09-06 16:39 ` Linus Torvalds
2021-09-06 17:35   ` Vlad Buslov [this message]
2021-09-07 20:34     ` Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ygnhk0jtwqs6.fsf@nvidia.com \
    --to=vladbu@nvidia.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.