* [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule()
@ 2022-08-25 18:06 Nathan Chancellor
2022-08-25 18:19 ` Nick Desaulniers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nathan Chancellor @ 2022-08-25 18:06 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Nick Desaulniers, Tom Rix, netdev, linux-rdma, linux-kernel,
llvm, patches, Nathan Chancellor
Clang warns:
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (IS_ERR(flow_rule)) {
^~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here
return err;
^~~
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:2: note: remove the 'if' if its condition is always true
if (IS_ERR(flow_rule)) {
^~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:474:9: note: initialize the variable 'err' to silence this warning
int err;
^
= 0
1 error generated.
There is little reason to have the 'goto + error variable' construct in
this function. Get rid of it and just return the PTR_ERR value in the if
statement and 0 at the end.
Fixes: 430e2d5e2a98 ("net/mlx5: E-Switch, Move send to vport meta rule creation")
Link: https://github.com/ClangBuiltLinux/linux/issues/1695
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index c8617a62e542..a977804137a8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -471,22 +471,18 @@ mlx5e_rep_add_meta_tunnel_rule(struct mlx5e_priv *priv)
struct mlx5_eswitch_rep *rep = rpriv->rep;
struct mlx5_flow_handle *flow_rule;
struct mlx5_flow_group *g;
- int err;
g = esw->fdb_table.offloads.send_to_vport_meta_grp;
if (!g)
return 0;
flow_rule = mlx5_eswitch_add_send_to_vport_meta_rule(esw, rep->vport);
- if (IS_ERR(flow_rule)) {
- err = PTR_ERR(flow_rule);
- goto out;
- }
+ if (IS_ERR(flow_rule))
+ return PTR_ERR(flow_rule);
rpriv->send_to_vport_meta_rule = flow_rule;
-out:
- return err;
+ return 0;
}
static void
base-commit: c19d893fbf3f2f8fa864ae39652c7fee939edde2
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule()
2022-08-25 18:06 [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule() Nathan Chancellor
@ 2022-08-25 18:19 ` Nick Desaulniers
2022-08-28 9:55 ` Leon Romanovsky
2022-08-31 6:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2022-08-25 18:19 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Saeed Mahameed, Leon Romanovsky, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Tom Rix, netdev, linux-rdma,
linux-kernel, llvm, patches
On Thu, Aug 25, 2022 at 11:06 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Clang warns:
>
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> if (IS_ERR(flow_rule)) {
> ^~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here
> return err;
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:2: note: remove the 'if' if its condition is always true
> if (IS_ERR(flow_rule)) {
> ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:474:9: note: initialize the variable 'err' to silence this warning
> int err;
> ^
> = 0
> 1 error generated.
>
> There is little reason to have the 'goto + error variable' construct in
> this function. Get rid of it and just return the PTR_ERR value in the if
> statement and 0 at the end.
>
> Fixes: 430e2d5e2a98 ("net/mlx5: E-Switch, Move send to vport meta rule creation")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1695
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks for the fix!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index c8617a62e542..a977804137a8 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -471,22 +471,18 @@ mlx5e_rep_add_meta_tunnel_rule(struct mlx5e_priv *priv)
> struct mlx5_eswitch_rep *rep = rpriv->rep;
> struct mlx5_flow_handle *flow_rule;
> struct mlx5_flow_group *g;
> - int err;
>
> g = esw->fdb_table.offloads.send_to_vport_meta_grp;
> if (!g)
> return 0;
>
> flow_rule = mlx5_eswitch_add_send_to_vport_meta_rule(esw, rep->vport);
> - if (IS_ERR(flow_rule)) {
> - err = PTR_ERR(flow_rule);
> - goto out;
> - }
> + if (IS_ERR(flow_rule))
> + return PTR_ERR(flow_rule);
>
> rpriv->send_to_vport_meta_rule = flow_rule;
>
> -out:
> - return err;
> + return 0;
> }
>
> static void
>
> base-commit: c19d893fbf3f2f8fa864ae39652c7fee939edde2
> --
> 2.37.2
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule()
2022-08-25 18:06 [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule() Nathan Chancellor
2022-08-25 18:19 ` Nick Desaulniers
@ 2022-08-28 9:55 ` Leon Romanovsky
2022-08-31 6:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2022-08-28 9:55 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Saeed Mahameed, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Nick Desaulniers, Tom Rix, netdev, linux-rdma,
linux-kernel, llvm, patches
On Thu, Aug 25, 2022 at 11:06:07AM -0700, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> if (IS_ERR(flow_rule)) {
> ^~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here
> return err;
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:2: note: remove the 'if' if its condition is always true
> if (IS_ERR(flow_rule)) {
> ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:474:9: note: initialize the variable 'err' to silence this warning
> int err;
> ^
> = 0
> 1 error generated.
>
> There is little reason to have the 'goto + error variable' construct in
> this function. Get rid of it and just return the PTR_ERR value in the if
> statement and 0 at the end.
>
> Fixes: 430e2d5e2a98 ("net/mlx5: E-Switch, Move send to vport meta rule creation")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1695
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule()
2022-08-25 18:06 [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule() Nathan Chancellor
2022-08-25 18:19 ` Nick Desaulniers
2022-08-28 9:55 ` Leon Romanovsky
@ 2022-08-31 6:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-31 6:30 UTC (permalink / raw)
To: Nathan Chancellor
Cc: saeedm, leon, davem, edumazet, kuba, pabeni, ndesaulniers, trix,
netdev, linux-rdma, linux-kernel, llvm, patches
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 25 Aug 2022 11:06:07 -0700 you wrote:
> Clang warns:
>
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> if (IS_ERR(flow_rule)) {
> ^~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here
> return err;
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:2: note: remove the 'if' if its condition is always true
> if (IS_ERR(flow_rule)) {
> ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:474:9: note: initialize the variable 'err' to silence this warning
> int err;
> ^
> = 0
> 1 error generated.
>
> [...]
Here is the summary with links:
- [net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule()
https://git.kernel.org/netdev/net-next/c/92f97c00f0ca
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-31 6:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 18:06 [PATCH net-next] net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule() Nathan Chancellor
2022-08-25 18:19 ` Nick Desaulniers
2022-08-28 9:55 ` Leon Romanovsky
2022-08-31 6:30 ` patchwork-bot+netdevbpf
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).