}
 
 static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
-                                      struct ib_udata *ucore,
                                       struct ib_uverbs_ex_create_cq *cmd,
                                       size_t cmd_sz,
                                       int (*cb)(struct uverbs_attr_bundle *attrs,
                                                 struct ib_ucq_object *obj,
                                                 struct ib_uverbs_ex_create_cq_resp *resp,
-                                                struct ib_udata *ucore,
                                                 void *context),
                                       void *context)
 {
        cq->res.type = RDMA_RESTRACK_CQ;
        rdma_restrack_add(&cq->res);
 
-       ret = cb(attrs, obj, &resp, ucore, context);
+       ret = cb(attrs, obj, &resp, context);
        if (ret)
                goto err_cb;
 
 static int ib_uverbs_create_cq_cb(struct uverbs_attr_bundle *attrs,
                                  struct ib_ucq_object *obj,
                                  struct ib_uverbs_ex_create_cq_resp *resp,
-                                 struct ib_udata *ucore, void *context)
+                                 void *context)
 {
-       if (ib_copy_to_udata(ucore, &resp->base, sizeof(resp->base)))
+       if (ib_copy_to_udata(&attrs->ucore, &resp->base, sizeof(resp->base)))
                return -EFAULT;
 
        return 0;
 {
        struct ib_uverbs_create_cq      cmd;
        struct ib_uverbs_ex_create_cq   cmd_ex;
-       struct ib_uverbs_create_cq_resp resp;
-       struct ib_udata                 ucore;
        struct ib_ucq_object           *obj;
 
        if (copy_from_user(&cmd, buf, sizeof(cmd)))
                return -EFAULT;
 
-       ib_uverbs_init_udata(&ucore, buf, u64_to_user_ptr(cmd.response),
-                            sizeof(cmd), sizeof(resp));
-
        memset(&cmd_ex, 0, sizeof(cmd_ex));
        cmd_ex.user_handle = cmd.user_handle;
        cmd_ex.cqe = cmd.cqe;
        cmd_ex.comp_vector = cmd.comp_vector;
        cmd_ex.comp_channel = cmd.comp_channel;
 
-       obj = create_cq(attrs, &ucore, &cmd_ex,
+       obj = create_cq(attrs, &cmd_ex,
                        offsetof(typeof(cmd_ex), comp_channel) +
                                sizeof(cmd.comp_channel),
                        ib_uverbs_create_cq_cb, NULL);
 static int ib_uverbs_ex_create_cq_cb(struct uverbs_attr_bundle *attrs,
                                     struct ib_ucq_object *obj,
                                     struct ib_uverbs_ex_create_cq_resp *resp,
-                                    struct ib_udata *ucore, void *context)
+                                    void *context)
 {
-       if (ib_copy_to_udata(ucore, resp, resp->response_length))
+       if (ib_copy_to_udata(&attrs->ucore, resp, resp->response_length))
                return -EFAULT;
 
        return 0;
                             sizeof(resp.response_length)))
                return -ENOSPC;
 
-       obj = create_cq(attrs, ucore, &cmd, min(ucore->inlen, sizeof(cmd)),
+       obj = create_cq(attrs, &cmd, min(ucore->inlen, sizeof(cmd)),
                        ib_uverbs_ex_create_cq_cb, NULL);
 
        return PTR_ERR_OR_ZERO(obj);
                return -EINVAL;
 
        /* we copy a struct ib_uverbs_poll_cq_resp to user space */
-       header_ptr = u64_to_user_ptr(cmd.response);
+       header_ptr = attrs->ucore.outbuf;
        data_ptr = header_ptr + sizeof resp;
 
        memset(&resp, 0, sizeof resp);
 }
 
 static int create_qp(struct uverbs_attr_bundle *attrs,
-                    struct ib_udata *ucore,
-                    struct ib_uverbs_ex_create_qp *cmd,
-                    size_t cmd_sz,
+                    struct ib_uverbs_ex_create_qp *cmd, size_t cmd_sz,
                     int (*cb)(struct uverbs_attr_bundle *attrs,
-                              struct ib_uverbs_ex_create_qp_resp *resp,
-                              struct ib_udata *udata),
+                              struct ib_uverbs_ex_create_qp_resp *resp),
                     void *context)
 {
        struct ib_uqp_object            *obj;
        }
 
        if (cmd_sz > sizeof(*cmd) &&
-           !ib_is_udata_cleared(ucore, sizeof(*cmd),
+           !ib_is_udata_cleared(&attrs->ucore, sizeof(*cmd),
                                 cmd_sz - sizeof(*cmd))) {
                ret = -EOPNOTSUPP;
                goto err_put;
        resp.response_length = offsetof(typeof(resp), response_length) +
                               sizeof(resp.response_length);
 
-       ret = cb(attrs, &resp, ucore);
+       ret = cb(attrs, &resp);
        if (ret)
                goto err_cb;
 
 }
 
 static int ib_uverbs_create_qp_cb(struct uverbs_attr_bundle *attrs,
-                                 struct ib_uverbs_ex_create_qp_resp *resp,
-                                 struct ib_udata *ucore)
+                                 struct ib_uverbs_ex_create_qp_resp *resp)
 {
-       if (ib_copy_to_udata(ucore, &resp->base, sizeof(resp->base)))
+       if (ib_copy_to_udata(&attrs->ucore, &resp->base, sizeof(resp->base)))
                return -EFAULT;
 
        return 0;
 {
        struct ib_uverbs_create_qp      cmd;
        struct ib_uverbs_ex_create_qp   cmd_ex;
-       struct ib_udata                 ucore;
-       ssize_t resp_size = sizeof(struct ib_uverbs_create_qp_resp);
        int                             err;
 
        if (copy_from_user(&cmd, buf, sizeof(cmd)))
                return -EFAULT;
 
-       ib_uverbs_init_udata(&ucore, buf, u64_to_user_ptr(cmd.response),
-                  sizeof(cmd), resp_size);
-
        memset(&cmd_ex, 0, sizeof(cmd_ex));
        cmd_ex.user_handle = cmd.user_handle;
        cmd_ex.pd_handle = cmd.pd_handle;
        cmd_ex.qp_type = cmd.qp_type;
        cmd_ex.is_srq = cmd.is_srq;
 
-       err = create_qp(attrs, &ucore, &cmd_ex,
+       err = create_qp(attrs, &cmd_ex,
                        offsetof(typeof(cmd_ex), is_srq) + sizeof(cmd.is_srq),
                        ib_uverbs_create_qp_cb, NULL);
 
 }
 
 static int ib_uverbs_ex_create_qp_cb(struct uverbs_attr_bundle *attrs,
-                                    struct ib_uverbs_ex_create_qp_resp *resp,
-                                    struct ib_udata *ucore)
+                                    struct ib_uverbs_ex_create_qp_resp *resp)
 {
-       if (ib_copy_to_udata(ucore, resp, resp->response_length))
+       if (ib_copy_to_udata(&attrs->ucore, resp, resp->response_length))
                return -EFAULT;
 
        return 0;
                             sizeof(resp.response_length)))
                return -ENOSPC;
 
-       err = create_qp(attrs, ucore, &cmd,
+       err = create_qp(attrs, &cmd,
                        min(ucore->inlen, sizeof(cmd)),
                        ib_uverbs_ex_create_qp_cb, NULL);
 
 
        if (!method_elm->is_ex) {
                size_t in_len = hdr.in_words * 4 - sizeof(hdr);
                size_t out_len = hdr.out_words * 4;
+               u64 response = 0;
 
                if (method_elm->has_udata) {
                        bundle.driver_udata.inlen =
                }
 
                if (method_elm->has_resp) {
-                       u64 response;
-
                        /*
                         * The macros check that if has_resp is set
                         * then the command request structure starts
                        bundle.driver_udata.outbuf = NULL;
                }
 
+               ib_uverbs_init_udata_buf_or_null(
+                       &bundle.ucore, buf, u64_to_user_ptr(response),
+                       in_len, out_len);
+
                ret = method_elm->handler(&bundle, buf, in_len, out_len);
        } else {
-               struct ib_udata ucore;
-
                buf += sizeof(ex_hdr);
 
-               ib_uverbs_init_udata_buf_or_null(&ucore, buf,
+               ib_uverbs_init_udata_buf_or_null(&bundle.ucore, buf,
                                        u64_to_user_ptr(ex_hdr.response),
                                        hdr.in_words * 8, hdr.out_words * 8);
 
-               ib_uverbs_init_udata_buf_or_null(&bundle.driver_udata,
-                                       buf + ucore.inlen,
-                                       u64_to_user_ptr(ex_hdr.response) + ucore.outlen,
-                                       ex_hdr.provider_in_words * 8,
-                                       ex_hdr.provider_out_words * 8);
+               ib_uverbs_init_udata_buf_or_null(
+                       &bundle.driver_udata, buf + bundle.ucore.inlen,
+                       u64_to_user_ptr(ex_hdr.response) + bundle.ucore.outlen,
+                       ex_hdr.provider_in_words * 8,
+                       ex_hdr.provider_out_words * 8);
 
-               ret = method_elm->handler_ex(&bundle, &ucore);
+               ret = method_elm->handler_ex(&bundle, &bundle.ucore);
        }
 
 out_unlock: