forked from Minki/linux
net/mlx5e: Ensure macsec_rule is always initiailized in macsec_fs_{r,t}x_add_rule()
Clang warns: drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:539:6: error: variable 'macsec_rule' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (err) ^~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:598:9: note: uninitialized use occurs here return macsec_rule; ^~~~~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:539:2: note: remove the 'if' if its condition is always false if (err) ^~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:523:38: note: initialize the variable 'macsec_rule' to silence this warning union mlx5e_macsec_rule *macsec_rule; ^ = NULL drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1131:6: error: variable 'macsec_rule' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (err) ^~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1215:9: note: uninitialized use occurs here return macsec_rule; ^~~~~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1131:2: note: remove the 'if' if its condition is always false if (err) ^~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_fs.c:1118:38: note: initialize the variable 'macsec_rule' to silence this warning union mlx5e_macsec_rule *macsec_rule; ^ = NULL 2 errors generated. If macsec_fs_{r,t}x_ft_get() fail, macsec_rule will be uninitialized. Initialize it to NULL at the top of each function so that it cannot be used uninitialized. Fixes:e467b283ff
("net/mlx5e: Add MACsec TX steering rules") Fixes:3b20949cb2
("net/mlx5e: Add MACsec RX steering rules") Link: https://github.com/ClangBuiltLinux/linux/issues/1706 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Raed Salem <raeds@nvidia.com> Link: https://lore.kernel.org/r/20220911085748.461033-1-nathan@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
e8b9f0da92
commit
2e50e9bf32
@ -518,9 +518,9 @@ macsec_fs_tx_add_rule(struct mlx5e_macsec_fs *macsec_fs,
|
|||||||
struct mlx5_pkt_reformat_params reformat_params = {};
|
struct mlx5_pkt_reformat_params reformat_params = {};
|
||||||
struct mlx5e_macsec_tx *tx_fs = macsec_fs->tx_fs;
|
struct mlx5e_macsec_tx *tx_fs = macsec_fs->tx_fs;
|
||||||
struct net_device *netdev = macsec_fs->netdev;
|
struct net_device *netdev = macsec_fs->netdev;
|
||||||
|
union mlx5e_macsec_rule *macsec_rule = NULL;
|
||||||
struct mlx5_flow_destination dest = {};
|
struct mlx5_flow_destination dest = {};
|
||||||
struct mlx5e_macsec_tables *tx_tables;
|
struct mlx5e_macsec_tables *tx_tables;
|
||||||
union mlx5e_macsec_rule *macsec_rule;
|
|
||||||
struct mlx5e_macsec_tx_rule *tx_rule;
|
struct mlx5e_macsec_tx_rule *tx_rule;
|
||||||
struct mlx5_flow_act flow_act = {};
|
struct mlx5_flow_act flow_act = {};
|
||||||
struct mlx5_flow_handle *rule;
|
struct mlx5_flow_handle *rule;
|
||||||
@ -1112,10 +1112,10 @@ macsec_fs_rx_add_rule(struct mlx5e_macsec_fs *macsec_fs,
|
|||||||
u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {};
|
u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {};
|
||||||
struct mlx5e_macsec_rx *rx_fs = macsec_fs->rx_fs;
|
struct mlx5e_macsec_rx *rx_fs = macsec_fs->rx_fs;
|
||||||
struct net_device *netdev = macsec_fs->netdev;
|
struct net_device *netdev = macsec_fs->netdev;
|
||||||
|
union mlx5e_macsec_rule *macsec_rule = NULL;
|
||||||
struct mlx5_modify_hdr *modify_hdr = NULL;
|
struct mlx5_modify_hdr *modify_hdr = NULL;
|
||||||
struct mlx5_flow_destination dest = {};
|
struct mlx5_flow_destination dest = {};
|
||||||
struct mlx5e_macsec_tables *rx_tables;
|
struct mlx5e_macsec_tables *rx_tables;
|
||||||
union mlx5e_macsec_rule *macsec_rule;
|
|
||||||
struct mlx5e_macsec_rx_rule *rx_rule;
|
struct mlx5e_macsec_rx_rule *rx_rule;
|
||||||
struct mlx5_flow_act flow_act = {};
|
struct mlx5_flow_act flow_act = {};
|
||||||
struct mlx5e_flow_table *ft_crypto;
|
struct mlx5e_flow_table *ft_crypto;
|
||||||
|
Loading…
Reference in New Issue
Block a user