Skip to content

Commit 88de869

Browse files
Leon Romanovskydledford
authored andcommitted
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 <[email protected]> Reviewed-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 75a4598 commit 88de869

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,13 @@ static int modify_qp(struct ib_uverbs_file *file,
19911991
goto release_qp;
19921992
}
19931993

1994+
if ((cmd->base.attr_mask & IB_QP_CUR_STATE &&
1995+
cmd->base.cur_qp_state > IB_QPS_ERR) ||
1996+
cmd->base.qp_state > IB_QPS_ERR) {
1997+
ret = -EINVAL;
1998+
goto release_qp;
1999+
}
2000+
19942001
attr->qp_state = cmd->base.qp_state;
19952002
attr->cur_qp_state = cmd->base.cur_qp_state;
19962003
attr->path_mtu = cmd->base.path_mtu;

0 commit comments

Comments
 (0)