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

Commit 51ee86a4 authored by Eli Cohen's avatar Eli Cohen Committed by Roland Dreier
Browse files

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: default avatarEli Cohen <eli@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 959f5854
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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);