diff mbox series

[next] net/mlx5: Fix bit-wise and with zero

Message ID 20210406165346.430535-1-colin.king@canonical.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [next] net/mlx5: Fix bit-wise and with zero | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 2 maintainers not CCed: roid@nvidia.com tariqt@nvidia.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Colin King April 6, 2021, 4:53 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The bit-wise and of the action field with MLX5_ACCEL_ESP_ACTION_DECRYPT
is incorrect as MLX5_ACCEL_ESP_ACTION_DECRYPT is zero and not intended
to be a bit-flag. Fix this by using the == operator as was originally
intended.

Addresses-Coverity: ("Logically dead code")
Fixes: 7dfee4b1d79e ("net/mlx5: IPsec, Refactor SA handle creation and destruction")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurence Oberman April 6, 2021, 9:13 p.m. UTC | #1
On Tue, 2021-04-06 at 17:53 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The bit-wise and of the action field with
> MLX5_ACCEL_ESP_ACTION_DECRYPT
> is incorrect as MLX5_ACCEL_ESP_ACTION_DECRYPT is zero and not
> intended
> to be a bit-flag. Fix this by using the == operator as was originally
> intended.
> 
> Addresses-Coverity: ("Logically dead code")
> Fixes: 7dfee4b1d79e ("net/mlx5: IPsec, Refactor SA handle creation
> and destruction")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> index d43a05e77f67..0b19293cdd74 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> @@ -850,7 +850,7 @@ mlx5_fpga_ipsec_release_sa_ctx(struct
> mlx5_fpga_ipsec_sa_ctx *sa_ctx)
>  		return;
>  	}
>  
> -	if (sa_ctx->fpga_xfrm->accel_xfrm.attrs.action &
> +	if (sa_ctx->fpga_xfrm->accel_xfrm.attrs.action ==
>  	    MLX5_ACCEL_ESP_ACTION_DECRYPT)
>  		ida_free(&fipsec->halloc, sa_ctx->sa_handle);
>  

Looks correct to me with enum mlx5_accel_esp_action action;

Reviewed-by Laurence Oberman <loberman@redhat.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
index d43a05e77f67..0b19293cdd74 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
@@ -850,7 +850,7 @@  mlx5_fpga_ipsec_release_sa_ctx(struct mlx5_fpga_ipsec_sa_ctx *sa_ctx)
 		return;
 	}
 
-	if (sa_ctx->fpga_xfrm->accel_xfrm.attrs.action &
+	if (sa_ctx->fpga_xfrm->accel_xfrm.attrs.action ==
 	    MLX5_ACCEL_ESP_ACTION_DECRYPT)
 		ida_free(&fipsec->halloc, sa_ctx->sa_handle);