Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c4c3774 authored by Noa Osherovich's avatar Noa Osherovich Committed by Doug Ledford
Browse files

IB/mlx5: Fix entries check in mlx5_ib_resize_cq



Verify that number of entries is less than device capability.
Add an appropriate warning message for error flow.

Fixes: bde51583 ('IB/mlx5: Add support for resize CQ')
Signed-off-by: default avatarMajd Dibbiny <majd@mellanox.com>
Signed-off-by: default avatarNoa Osherovich <noaos@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 9ea57852
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1169,8 +1169,13 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
		return -ENOSYS;
	}

	if (entries < 1)
	if (entries < 1 ||
	    entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))) {
		mlx5_ib_warn(dev, "wrong entries number %d, max %d\n",
			     entries,
			     1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz));
		return -EINVAL;
	}

	entries = roundup_pow_of_two(entries + 1);
	if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1)