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 check of number of entries in create CQ
Verify that the value is non negative before rounding up to power of 2. Signed-off-by: Eli Cohen <eli@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
This commit is contained in:
parent
959f58544b
commit
51ee86a4af
1 changed files with 4 additions and 1 deletions
|
@ -653,8 +653,11 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries,
|
||||||
int eqn;
|
int eqn;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (entries < 0)
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
entries = roundup_pow_of_two(entries + 1);
|
entries = roundup_pow_of_two(entries + 1);
|
||||||
if (entries < 1 || entries > dev->mdev.caps.max_cqes)
|
if (entries > dev->mdev.caps.max_cqes)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
cq = kzalloc(sizeof(*cq), GFP_KERNEL);
|
cq = kzalloc(sizeof(*cq), GFP_KERNEL);
|
||||||
|
|
Loading…
Reference in a new issue