From: Leon Romanovsky <leonro@nvidia.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Saeed Mahameed <saeedm@nvidia.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
Mark Bloch <mbloch@nvidia.com>,
Naresh Kamboju <naresh.kamboju@linaro.org>,
<netdev@vger.kernel.org>, Roi Dayan <roid@nvidia.com>,
Vlad Buslov <vladbu@nvidia.com>
Subject: Re: [PATCH net-next] net/mlx5: Fix use of uninitialized variable in bridge.c
Date: Tue, 14 Sep 2021 15:41:23 +0300 [thread overview]
Message-ID: <YUCYc7XkOVWS8h1F@unreal> (raw)
In-Reply-To: <9e9eb5df93dbcba6faff199d71222785c1f1faf7.1631621485.git.leonro@nvidia.com>
On Tue, Sep 14, 2021 at 03:12:47PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> Rewrite the code to fix the following compilation warnings that were
> discovered once Linus enabled -Werror flag.
>
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:157:11: error:
> variable 'err' is used uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
> else if (mlx5_esw_bridge_dev_same_hw(rep, esw))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:164:9: note:
> uninitialized use occurs here
> return err;
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:157:7: note:
> remove the 'if' if its condition is always true
> else if (mlx5_esw_bridge_dev_same_hw(rep, esw))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:140:9: note:
> initialize the variable 'err' to silence this warning
> int err;
> ^
> = 0
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:262:7: error:
> variable 'err' is used uninitialized whenever switch case is taken
> [-Werror,-Wsometimes-uninitialized]
> case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:276:9: note:
> uninitialized use occurs here
> return err;
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:257:7: error:
> variable 'err' is used uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
> if (attr->u.brport_flags.mask & ~(BR_LEARNING |
> BR_FLOOD | BR_MCAST_FLOOD)) {
>
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:276:9: note:
> uninitialized use occurs here
> return err;
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:257:3: note:
> remove the 'if' if its condition is always true
> if (attr->u.brport_flags.mask & ~(BR_LEARNING |
> BR_FLOOD | BR_MCAST_FLOOD)) {
>
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c:247:9: note:
> initialize the variable 'err' to silence this warning
> int err;
> ^
> = 0
> 3 errors generated.
>
> Fixes: ff9b7521468b ("net/mlx5: Bridge, support LAG")
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> .../mellanox/mlx5/core/en/rep/bridge.c | 36 +++++++++++--------
> 1 file changed, 22 insertions(+), 14 deletions(-)
Vlad pointed to me that similar patch was already accepted.
https://patchwork.kernel.org/project/netdevbpf/patch/20210907212420.28529-2-saeed@kernel.org/
Can we please expedite the fix to Linus so our other branches (RDMA e.t.c)
that are based on pure -rcX from Linus will be compilation error free?
Thanks
prev parent reply other threads:[~2021-09-14 12:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 12:12 [PATCH net-next] net/mlx5: Fix use of uninitialized variable in bridge.c Leon Romanovsky
2021-09-14 12:41 ` Leon Romanovsky [this message]
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=YUCYc7XkOVWS8h1F@unreal \
--to=leonro@nvidia.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=naresh.kamboju@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=roid@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=vladbu@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).