From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> write() methods must work with fixed sized structures as that is the only way to know where the udata segment starts. The common udata code now rejects any write() that has a response buffer shorter than the core's response. Thus all the checks of out_len for write methods are redundant and can be removed. Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/core/uverbs_cmd.c | 50 ---------------------------- 1 file changed, 50 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 8ee9e94e25fe..4b8e131adbf0 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -78,9 +78,6 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs, struct ib_device *ib_dev; int ret; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -231,9 +228,6 @@ static int ib_uverbs_query_device(struct uverbs_attr_bundle *attrs, if (IS_ERR(ucontext)) return PTR_ERR(ucontext); - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -282,9 +276,6 @@ static int ib_uverbs_query_port(struct uverbs_attr_bundle *attrs, return PTR_ERR(ucontext); ib_dev = ucontext->device; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -341,9 +332,6 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs, int ret; struct ib_device *ib_dev; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -493,9 +481,6 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs, int new_xrcd = 0; struct ib_device *ib_dev; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -642,9 +627,6 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs, int ret; struct ib_device *ib_dev; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -727,9 +709,6 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs, int ret; struct ib_uobject *uobj; - if (out_len < sizeof(resp)) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof(cmd))) return -EFAULT; @@ -822,9 +801,6 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs, int ret; struct ib_device *ib_dev; - if (out_len < sizeof(resp)) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof(cmd))) return -EFAULT; @@ -893,9 +869,6 @@ static int ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs, struct ib_uverbs_completion_event_file *ev_file; struct ib_device *ib_dev; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -1031,9 +1004,6 @@ static int ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs, struct ib_udata ucore; struct ib_ucq_object *obj; - if (out_len < sizeof(resp)) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof(cmd))) return -EFAULT; @@ -1553,9 +1523,6 @@ static int ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs, ssize_t resp_size = sizeof(struct ib_uverbs_create_qp_resp); int err; - if (out_len < resp_size) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof(cmd))) return -EFAULT; @@ -1645,9 +1612,6 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs, int ret; struct ib_device *ib_dev; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -2480,9 +2444,6 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs, int ret; struct ib_device *ib_dev; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -3671,10 +3632,6 @@ static int ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs, { struct ib_uverbs_create_srq cmd; struct ib_uverbs_create_xsrq xcmd; - struct ib_uverbs_create_srq_resp resp; - - if (out_len < sizeof resp) - return -ENOSPC; if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -3696,10 +3653,6 @@ static int ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, int out_len) { struct ib_uverbs_create_xsrq cmd; - struct ib_uverbs_create_srq_resp resp; - - if (out_len < sizeof resp) - return -ENOSPC; if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -3742,9 +3695,6 @@ static int ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs, struct ib_srq *srq; int ret; - if (out_len < sizeof resp) - return -ENOSPC; - if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; -- 2.19.1