mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
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: bde51583f4
('IB/mlx5: Add support for resize CQ')
Signed-off-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
9ea5785286
commit
3c4c37746c
1 changed files with 7 additions and 2 deletions
|
@ -1169,11 +1169,16 @@ 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)
|
||||
if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1)
|
||||
return -EINVAL;
|
||||
|
||||
if (entries == ibcq->cqe + 1)
|
||||
|
|
Loading…
Reference in a new issue