Commit 72d3fef1 authored by Raed Salem's avatar Raed Salem Committed by Saeed Mahameed

net/mlx5: IPsec, Fix coverity issue

The cited commit introduced the following coverity issue at functions
mlx5_fpga_is_ipsec_device() and mlx5_fpga_ipsec_release_sa_ctx():
- bit_and_with_zero:
  accel_xfrm->attrs.action & MLX5_ACCEL_ESP_ACTION_DECRYPT is always 0.

As MLX5_ACCEL_ESP_ACTION_DECRYPT is not a bitwise flag and was wrongly
used with bitwise operation, the above expression is always zero value
as MLX5_ACCEL_ESP_ACTION_DECRYPT is zero.

Fix by using "==" comparison operator instead.

Fixes: 7dfee4b1 ("net/mlx5: IPsec, Refactor SA handle creation and destruction")
Signed-off-by: default avatarRaed Salem <raeds@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent a6b1b936
...@@ -708,7 +708,7 @@ void *mlx5_fpga_ipsec_create_sa_ctx(struct mlx5_core_dev *mdev, ...@@ -708,7 +708,7 @@ void *mlx5_fpga_ipsec_create_sa_ctx(struct mlx5_core_dev *mdev,
goto exists; goto exists;
} }
if (accel_xfrm->attrs.action & MLX5_ACCEL_ESP_ACTION_DECRYPT) { if (accel_xfrm->attrs.action == MLX5_ACCEL_ESP_ACTION_DECRYPT) {
err = ida_simple_get(&fipsec->halloc, 1, 0, GFP_KERNEL); err = ida_simple_get(&fipsec->halloc, 1, 0, GFP_KERNEL);
if (err < 0) { if (err < 0) {
context = ERR_PTR(err); context = ERR_PTR(err);
...@@ -759,7 +759,7 @@ void *mlx5_fpga_ipsec_create_sa_ctx(struct mlx5_core_dev *mdev, ...@@ -759,7 +759,7 @@ void *mlx5_fpga_ipsec_create_sa_ctx(struct mlx5_core_dev *mdev,
rhash_sa)); rhash_sa));
unlock_hash: unlock_hash:
mutex_unlock(&fipsec->sa_hash_lock); mutex_unlock(&fipsec->sa_hash_lock);
if (accel_xfrm->attrs.action & MLX5_ACCEL_ESP_ACTION_DECRYPT) if (accel_xfrm->attrs.action == MLX5_ACCEL_ESP_ACTION_DECRYPT)
ida_simple_remove(&fipsec->halloc, sa_ctx->sa_handle); ida_simple_remove(&fipsec->halloc, sa_ctx->sa_handle);
exists: exists:
mutex_unlock(&fpga_xfrm->lock); mutex_unlock(&fpga_xfrm->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment