aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoa Osherovich <noaos@mellanox.com>2018-02-25 06:39:51 -0500
committerJason Gunthorpe <jgg@mellanox.com>2018-02-28 14:10:32 -0500
commite7b169f34403becd3c9fd3b6e46614ab788f2187 (patch)
tree09109754cba1a79920cf746d0a6571e8db89a47f
parentda343b6d90e11132f1e917d865d88ee35d6e6d00 (diff)
IB/mlx5: Avoid passing an invalid QP type to firmware
During QP creation, the mlx5 driver translates the QP type to an internal value which is passed on to FW. There was no check to make sure that the translated value is valid, and -EINVAL was coerced into the mailbox command. Current firmware refuses this as an invalid QP type, but future/past firmware may do something else. Fixes: 09a7d9eca1a6c ('{net,IB}/mlx5: QP/XRCD commands via mlx5 ifc') Reviewed-by: Ilya Lesokhin <ilyal@mellanox.com> Signed-off-by: Noa Osherovich <noaos@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--drivers/infiniband/hw/mlx5/qp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 39d24bf694a8..e8d7eaf0670c 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1584,6 +1584,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
1584 u32 uidx = MLX5_IB_DEFAULT_UIDX; 1584 u32 uidx = MLX5_IB_DEFAULT_UIDX;
1585 struct mlx5_ib_create_qp ucmd; 1585 struct mlx5_ib_create_qp ucmd;
1586 struct mlx5_ib_qp_base *base; 1586 struct mlx5_ib_qp_base *base;
1587 int mlx5_st;
1587 void *qpc; 1588 void *qpc;
1588 u32 *in; 1589 u32 *in;
1589 int err; 1590 int err;
@@ -1592,6 +1593,10 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
1592 spin_lock_init(&qp->sq.lock); 1593 spin_lock_init(&qp->sq.lock);
1593 spin_lock_init(&qp->rq.lock); 1594 spin_lock_init(&qp->rq.lock);
1594 1595
1596 mlx5_st = to_mlx5_st(init_attr->qp_type);
1597 if (mlx5_st < 0)
1598 return -EINVAL;
1599
1595 if (init_attr->rwq_ind_tbl) { 1600 if (init_attr->rwq_ind_tbl) {
1596 if (!udata) 1601 if (!udata)
1597 return -ENOSYS; 1602 return -ENOSYS;
@@ -1753,7 +1758,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
1753 1758
1754 qpc = MLX5_ADDR_OF(create_qp_in, in, qpc); 1759 qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
1755 1760
1756 MLX5_SET(qpc, qpc, st, to_mlx5_st(init_attr->qp_type)); 1761 MLX5_SET(qpc, qpc, st, mlx5_st);
1757 MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED); 1762 MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
1758 1763
1759 if (init_attr->qp_type != MLX5_IB_QPT_REG_UMR) 1764 if (init_attr->qp_type != MLX5_IB_QPT_REG_UMR)