check_qp_type() checks the dct capability only for IB_QPT_DRIVER, but process_vendor_flags() turns any QP that carries a DC type flag into a DCI or DCT QP. A QP created as, for example, IB_QPT_RC with a DC flag thus becomes a DC QP without the capability check. Accept the DC type flags only on IB_QPT_DRIVER, the type userspace uses to create DC QPs. Fixes: 37518fa49f76 ("RDMA/mlx5: Process all vendor flags in one place") Signed-off-by: Yishai Hadas --- drivers/infiniband/hw/mlx5/qp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 943ee5c55538..19cbf6b2b979 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -2965,18 +2965,22 @@ static int process_vendor_flags(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, switch (flags & (MLX5_QP_FLAG_TYPE_DCT | MLX5_QP_FLAG_TYPE_DCI)) { case MLX5_QP_FLAG_TYPE_DCI: + if (qp->type != IB_QPT_DRIVER) + return -EINVAL; qp->type = MLX5_IB_QPT_DCI; break; case MLX5_QP_FLAG_TYPE_DCT: + if (qp->type != IB_QPT_DRIVER) + return -EINVAL; qp->type = MLX5_IB_QPT_DCT; break; + case 0: + /* IB_QPT_DRIVER needs a subtype */ + if (qp->type == IB_QPT_DRIVER) + return -EINVAL; + break; default: - if (qp->type != IB_QPT_DRIVER) - break; - /* - * It is IB_QPT_DRIVER and or no subtype or - * wrong subtype were provided. - */ + /* Both subtypes */ return -EINVAL; } -- 2.18.1