linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx5e: Return in default case statement in tx_post_resync_params
@ 2019-07-08 23:11 Nathan Chancellor
  2019-07-09 22:44 ` Nick Desaulniers
  2019-07-10  4:47 ` [PATCH v2] net/mlx5e: Refactor switch statements to avoid using uninitialized variables Nathan Chancellor
  0 siblings, 2 replies; 11+ messages in thread
From: Nathan Chancellor @ 2019-07-08 23:11 UTC (permalink / raw)
  To: Saeed Mahameed, Leon Romanovsky
  Cc: David S. Miller, Boris Pismenny, netdev, linux-rdma,
	linux-kernel, clang-built-linux, Nathan Chancellor

clang warns:

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:251:2:
warning: variable 'rec_seq_sz' is used uninitialized whenever switch
default is taken [-Wsometimes-uninitialized]
        default:
        ^~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:255:46: note:
uninitialized use occurs here
        skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
                                                    ^~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:239:16: note:
initialize the variable 'rec_seq_sz' to silence this warning
        u16 rec_seq_sz;
                      ^
                       = 0
1 warning generated.

This case statement was clearly designed to be one that should not be
hit during runtime because of the WARN_ON statement so just return early
to prevent copying uninitialized memory up into rn_be.

Fixes: d2ead1f360e8 ("net/mlx5e: Add kTLS TX HW offload support")
Link: https://github.com/ClangBuiltLinux/linux/issues/590
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
index 3f5f4317a22b..5c08891806f0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
@@ -250,6 +250,7 @@ tx_post_resync_params(struct mlx5e_txqsq *sq,
 	}
 	default:
 		WARN_ON(1);
+		return;
 	}
 
 	skip_static_post = !memcmp(rec_seq, &rn_be, rec_seq_sz);
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-07-12 18:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 23:11 [PATCH] net/mlx5e: Return in default case statement in tx_post_resync_params Nathan Chancellor
2019-07-09 22:44 ` Nick Desaulniers
2019-07-09 23:10   ` Nathan Chancellor
2019-07-10  4:24     ` Leon Romanovsky
2019-07-10  4:47 ` [PATCH v2] net/mlx5e: Refactor switch statements to avoid using uninitialized variables Nathan Chancellor
2019-07-10  5:22   ` Leon Romanovsky
2019-07-10  5:36   ` David Miller
2019-07-10  5:57     ` Nathan Chancellor
2019-07-10  6:06   ` [PATCH net-next v3] net/mlx5e: Convert single case statement switch statements into if statements Nathan Chancellor
2019-07-10  9:31     ` Leon Romanovsky
2019-07-12 18:37     ` David Miller

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).