mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
IB/mlx5: Avoid passing an invalid QP type to firmware
[ Upstream commite7b169f344] 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:09a7d9eca1('{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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a96406d439
commit
d287f1dab9
@@ -1523,6 +1523,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
u32 uidx = MLX5_IB_DEFAULT_UIDX;
|
||||
struct mlx5_ib_create_qp ucmd;
|
||||
struct mlx5_ib_qp_base *base;
|
||||
int mlx5_st;
|
||||
void *qpc;
|
||||
u32 *in;
|
||||
int err;
|
||||
@@ -1538,6 +1539,10 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
spin_lock_init(&qp->sq.lock);
|
||||
spin_lock_init(&qp->rq.lock);
|
||||
|
||||
mlx5_st = to_mlx5_st(init_attr->qp_type);
|
||||
if (mlx5_st < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (init_attr->rwq_ind_tbl) {
|
||||
if (!udata)
|
||||
return -ENOSYS;
|
||||
@@ -1665,7 +1670,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
|
||||
qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
|
||||
|
||||
MLX5_SET(qpc, qpc, st, to_mlx5_st(init_attr->qp_type));
|
||||
MLX5_SET(qpc, qpc, st, mlx5_st);
|
||||
MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
|
||||
|
||||
if (init_attr->qp_type != MLX5_IB_QPT_REG_UMR)
|
||||
|
||||
Reference in New Issue
Block a user