diff options
author | Eli Cohen <eli@dev.mellanox.co.il> | 2013-10-23 02:53:13 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-11-08 17:42:58 -0500 |
commit | 51ee86a4af639e4ee8953dd02ad8a766c40f46a1 (patch) | |
tree | 4cc3e7d5e75a5ae0e35682a340effe5ee6d278f0 /drivers/infiniband | |
parent | 959f58544b7f20c92d5eb43d1232c96c15c01bfb (diff) |
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>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/mlx5/cq.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 344ab03948a3..e7c64c57d699 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c | |||
@@ -653,8 +653,11 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries, | |||
653 | int eqn; | 653 | int eqn; |
654 | int err; | 654 | int err; |
655 | 655 | ||
656 | if (entries < 0) | ||
657 | return ERR_PTR(-EINVAL); | ||
658 | |||
656 | entries = roundup_pow_of_two(entries + 1); | 659 | entries = roundup_pow_of_two(entries + 1); |
657 | if (entries < 1 || entries > dev->mdev.caps.max_cqes) | 660 | if (entries > dev->mdev.caps.max_cqes) |
658 | return ERR_PTR(-EINVAL); | 661 | return ERR_PTR(-EINVAL); |
659 | 662 | ||
660 | cq = kzalloc(sizeof(*cq), GFP_KERNEL); | 663 | cq = kzalloc(sizeof(*cq), GFP_KERNEL); |