aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/uverbs_cmd.c
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2018-03-11 13:51:33 +0200
committerDoug Ledford <dledford@redhat.com>2018-03-14 15:34:25 -0400
commit88de869bbe4fb669ae92f19225a90b07d8173ccb (patch)
tree480cb2c799fe385db1c2dacc92c53286643d1a57 /drivers/infiniband/core/uverbs_cmd.c
parentRDMA/mlx5: Fix NULL dereference while accessing XRC_TGT QPs (diff)
downloadlinux-dev-88de869bbe4fb669ae92f19225a90b07d8173ccb.tar.xz
linux-dev-88de869bbe4fb669ae92f19225a90b07d8173ccb.zip
RDMA/uverbs: Ensure validity of current QP state value
The QP state is internal enum which is checked at the driver level by calling to ib_modify_qp_is_ok(). Move this check closer to user and leave kernel users to be checked by compiler. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to '')
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 9f9fc14523db..33c7f1290adb 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1991,6 +1991,13 @@ static int modify_qp(struct ib_uverbs_file *file,
goto release_qp;
}
+ if ((cmd->base.attr_mask & IB_QP_CUR_STATE &&
+ cmd->base.cur_qp_state > IB_QPS_ERR) ||
+ cmd->base.qp_state > IB_QPS_ERR) {
+ ret = -EINVAL;
+ goto release_qp;
+ }
+
attr->qp_state = cmd->base.qp_state;
attr->cur_qp_state = cmd->base.cur_qp_state;
attr->path_mtu = cmd->base.path_mtu;