Skip to content

Commit

Permalink
IB/mlx5: Fix check of number of entries in create CQ
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eli Cohen authored and Roland Dreier committed Nov 8, 2013
1 parent 959f585 commit 51ee86a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/infiniband/hw/mlx5/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,11 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries,
int eqn;
int err;

if (entries < 0)
return ERR_PTR(-EINVAL);

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);

cq = kzalloc(sizeof(*cq), GFP_KERNEL);
Expand Down

0 comments on commit 51ee86a

Please sign in to comment.