Commit 7106a976 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/uverbs: Make write() handlers return 0 on success

Currently they return the command length, while all other handlers return
0. This makes the write path closer to the write_ex and ioctl path.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent 8313c10f
...@@ -245,13 +245,11 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj, ...@@ -245,13 +245,11 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
} }
/* /*
* Does both uobj_get_destroy() and uobj_put_destroy(). Returns success_res * Does both uobj_get_destroy() and uobj_put_destroy(). Returns 0 on success
* on success (negative errno on failure). For use by callers that do not need * (negative errno on failure). For use by callers that do not need the uobj.
* the uobj.
*/ */
int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id, int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
const struct uverbs_attr_bundle *attrs, const struct uverbs_attr_bundle *attrs)
int success_res)
{ {
struct ib_uobject *uobj; struct ib_uobject *uobj;
...@@ -260,7 +258,7 @@ int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id, ...@@ -260,7 +258,7 @@ int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
return PTR_ERR(uobj); return PTR_ERR(uobj);
rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE);
return success_res; return 0;
} }
/* alloc_uobj must be undone by uverbs_destroy_uobject() */ /* alloc_uobj must be undone by uverbs_destroy_uobject() */
......
...@@ -137,8 +137,8 @@ struct uverbs_api_ioctl_method { ...@@ -137,8 +137,8 @@ struct uverbs_api_ioctl_method {
}; };
struct uverbs_api_write_method { struct uverbs_api_write_method {
ssize_t (*handler)(struct uverbs_attr_bundle *attrs, int (*handler)(struct uverbs_attr_bundle *attrs, const char __user *buf,
const char __user *buf, int in_len, int out_len); int in_len, int out_len);
int (*handler_ex)(struct uverbs_attr_bundle *attrs, int (*handler_ex)(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw); struct ib_udata *ucore, struct ib_udata *uhw);
u8 disabled:1; u8 disabled:1;
......
...@@ -65,7 +65,7 @@ _ib_uverbs_lookup_comp_file(s32 fd, const struct uverbs_attr_bundle *attrs) ...@@ -65,7 +65,7 @@ _ib_uverbs_lookup_comp_file(s32 fd, const struct uverbs_attr_bundle *attrs)
#define ib_uverbs_lookup_comp_file(_fd, _ufile) \ #define ib_uverbs_lookup_comp_file(_fd, _ufile) \
_ib_uverbs_lookup_comp_file((_fd)*typecheck(s32, _fd), _ufile) _ib_uverbs_lookup_comp_file((_fd)*typecheck(s32, _fd), _ufile)
static ssize_t ib_uverbs_get_context(struct uverbs_attr_bundle *attrs, static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -157,7 +157,7 @@ static ssize_t ib_uverbs_get_context(struct uverbs_attr_bundle *attrs, ...@@ -157,7 +157,7 @@ static ssize_t ib_uverbs_get_context(struct uverbs_attr_bundle *attrs,
mutex_unlock(&file->ucontext_lock); mutex_unlock(&file->ucontext_lock);
return in_len; return 0;
err_file: err_file:
ib_uverbs_free_async_event_file(file); ib_uverbs_free_async_event_file(file);
...@@ -225,7 +225,7 @@ static void copy_query_dev_fields(struct ib_ucontext *ucontext, ...@@ -225,7 +225,7 @@ static void copy_query_dev_fields(struct ib_ucontext *ucontext,
resp->phys_port_cnt = ib_dev->phys_port_cnt; resp->phys_port_cnt = ib_dev->phys_port_cnt;
} }
static ssize_t ib_uverbs_query_device(struct uverbs_attr_bundle *attrs, static int ib_uverbs_query_device(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -249,7 +249,7 @@ static ssize_t ib_uverbs_query_device(struct uverbs_attr_bundle *attrs, ...@@ -249,7 +249,7 @@ static ssize_t ib_uverbs_query_device(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp)) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp))
return -EFAULT; return -EFAULT;
return in_len; return 0;
} }
/* /*
...@@ -273,9 +273,8 @@ static u32 make_port_cap_flags(const struct ib_port_attr *attr) ...@@ -273,9 +273,8 @@ static u32 make_port_cap_flags(const struct ib_port_attr *attr)
return res; return res;
} }
static ssize_t ib_uverbs_query_port(struct uverbs_attr_bundle *attrs, static int ib_uverbs_query_port(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_query_port cmd; struct ib_uverbs_query_port cmd;
struct ib_uverbs_query_port_resp resp; struct ib_uverbs_query_port_resp resp;
...@@ -335,12 +334,11 @@ static ssize_t ib_uverbs_query_port(struct uverbs_attr_bundle *attrs, ...@@ -335,12 +334,11 @@ static ssize_t ib_uverbs_query_port(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp)) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp))
return -EFAULT; return -EFAULT;
return in_len; return 0;
} }
static ssize_t ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs, static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_alloc_pd cmd; struct ib_uverbs_alloc_pd cmd;
struct ib_uverbs_alloc_pd_resp resp; struct ib_uverbs_alloc_pd_resp resp;
...@@ -387,7 +385,7 @@ static ssize_t ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs, ...@@ -387,7 +385,7 @@ static ssize_t ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
goto err_copy; goto err_copy;
} }
return uobj_alloc_commit(uobj, in_len); return uobj_alloc_commit(uobj);
err_copy: err_copy:
ib_dealloc_pd(pd); ib_dealloc_pd(pd);
...@@ -397,17 +395,15 @@ static ssize_t ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs, ...@@ -397,17 +395,15 @@ static ssize_t ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_dealloc_pd(struct uverbs_attr_bundle *attrs, static int ib_uverbs_dealloc_pd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_dealloc_pd cmd; struct ib_uverbs_dealloc_pd cmd;
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
return uobj_perform_destroy(UVERBS_OBJECT_PD, cmd.pd_handle, attrs, return uobj_perform_destroy(UVERBS_OBJECT_PD, cmd.pd_handle, attrs);
in_len);
} }
struct xrcd_table_entry { struct xrcd_table_entry {
...@@ -495,9 +491,8 @@ static void xrcd_table_delete(struct ib_uverbs_device *dev, ...@@ -495,9 +491,8 @@ static void xrcd_table_delete(struct ib_uverbs_device *dev,
} }
} }
static ssize_t ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs, static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_device *ibudev = attrs->ufile->device; struct ib_uverbs_device *ibudev = attrs->ufile->device;
struct ib_uverbs_open_xrcd cmd; struct ib_uverbs_open_xrcd cmd;
...@@ -593,7 +588,7 @@ static ssize_t ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs, ...@@ -593,7 +588,7 @@ static ssize_t ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
mutex_unlock(&ibudev->xrcd_tree_mutex); mutex_unlock(&ibudev->xrcd_tree_mutex);
return uobj_alloc_commit(&obj->uobject, in_len); return uobj_alloc_commit(&obj->uobject);
err_copy: err_copy:
if (inode) { if (inode) {
...@@ -617,17 +612,15 @@ static ssize_t ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs, ...@@ -617,17 +612,15 @@ static ssize_t ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_close_xrcd(struct uverbs_attr_bundle *attrs, static int ib_uverbs_close_xrcd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_close_xrcd cmd; struct ib_uverbs_close_xrcd cmd;
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
return uobj_perform_destroy(UVERBS_OBJECT_XRCD, cmd.xrcd_handle, attrs, return uobj_perform_destroy(UVERBS_OBJECT_XRCD, cmd.xrcd_handle, attrs);
in_len);
} }
int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject,
...@@ -655,7 +648,7 @@ int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, ...@@ -655,7 +648,7 @@ int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject,
return ret; return ret;
} }
static ssize_t ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs, static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, int out_len) const char __user *buf, int in_len, int out_len)
{ {
struct ib_uverbs_reg_mr cmd; struct ib_uverbs_reg_mr cmd;
...@@ -733,7 +726,7 @@ static ssize_t ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs, ...@@ -733,7 +726,7 @@ static ssize_t ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(uobj, in_len); return uobj_alloc_commit(uobj);
err_copy: err_copy:
ib_dereg_mr(mr); ib_dereg_mr(mr);
...@@ -746,9 +739,8 @@ static ssize_t ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs, ...@@ -746,9 +739,8 @@ static ssize_t ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs, static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_rereg_mr cmd; struct ib_uverbs_rereg_mr cmd;
struct ib_uverbs_rereg_mr_resp resp; struct ib_uverbs_rereg_mr_resp resp;
...@@ -825,7 +817,7 @@ static ssize_t ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs, ...@@ -825,7 +817,7 @@ static ssize_t ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof(resp))) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof(resp)))
ret = -EFAULT; ret = -EFAULT;
else else
ret = in_len; ret = 0;
put_uobj_pd: put_uobj_pd:
if (cmd.flags & IB_MR_REREG_PD) if (cmd.flags & IB_MR_REREG_PD)
...@@ -837,22 +829,19 @@ static ssize_t ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs, ...@@ -837,22 +829,19 @@ static ssize_t ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_dereg_mr(struct uverbs_attr_bundle *attrs, static int ib_uverbs_dereg_mr(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_dereg_mr cmd; struct ib_uverbs_dereg_mr cmd;
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
return uobj_perform_destroy(UVERBS_OBJECT_MR, cmd.mr_handle, attrs, return uobj_perform_destroy(UVERBS_OBJECT_MR, cmd.mr_handle, attrs);
in_len);
} }
static ssize_t ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs, static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_alloc_mw cmd; struct ib_uverbs_alloc_mw cmd;
struct ib_uverbs_alloc_mw_resp resp; struct ib_uverbs_alloc_mw_resp resp;
...@@ -907,7 +896,7 @@ static ssize_t ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs, ...@@ -907,7 +896,7 @@ static ssize_t ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs,
} }
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(uobj, in_len); return uobj_alloc_commit(uobj);
err_copy: err_copy:
uverbs_dealloc_mw(mw); uverbs_dealloc_mw(mw);
...@@ -918,20 +907,18 @@ static ssize_t ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs, ...@@ -918,20 +907,18 @@ static ssize_t ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_dealloc_mw(struct uverbs_attr_bundle *attrs, static int ib_uverbs_dealloc_mw(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_dealloc_mw cmd; struct ib_uverbs_dealloc_mw cmd;
if (copy_from_user(&cmd, buf, sizeof(cmd))) if (copy_from_user(&cmd, buf, sizeof(cmd)))
return -EFAULT; return -EFAULT;
return uobj_perform_destroy(UVERBS_OBJECT_MW, cmd.mw_handle, attrs, return uobj_perform_destroy(UVERBS_OBJECT_MW, cmd.mw_handle, attrs);
in_len);
} }
static ssize_t ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs, static int ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -962,7 +949,7 @@ static ssize_t ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs, ...@@ -962,7 +949,7 @@ static ssize_t ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs,
return -EFAULT; return -EFAULT;
} }
return uobj_alloc_commit(uobj, in_len); return uobj_alloc_commit(uobj);
} }
static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
...@@ -1041,7 +1028,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1041,7 +1028,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
if (ret) if (ret)
goto err_cb; goto err_cb;
ret = uobj_alloc_commit(&obj->uobject, 0); ret = uobj_alloc_commit(&obj->uobject);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
return obj; return obj;
...@@ -1070,9 +1057,8 @@ static int ib_uverbs_create_cq_cb(struct uverbs_attr_bundle *attrs, ...@@ -1070,9 +1057,8 @@ static int ib_uverbs_create_cq_cb(struct uverbs_attr_bundle *attrs,
return 0; return 0;
} }
static ssize_t ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_create_cq cmd; struct ib_uverbs_create_cq cmd;
struct ib_uverbs_ex_create_cq cmd_ex; struct ib_uverbs_ex_create_cq cmd_ex;
...@@ -1109,7 +1095,7 @@ static ssize_t ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1109,7 +1095,7 @@ static ssize_t ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs,
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
return in_len; return 0;
} }
static int ib_uverbs_ex_create_cq_cb(struct uverbs_attr_bundle *attrs, static int ib_uverbs_ex_create_cq_cb(struct uverbs_attr_bundle *attrs,
...@@ -1155,9 +1141,8 @@ static int ib_uverbs_ex_create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1155,9 +1141,8 @@ static int ib_uverbs_ex_create_cq(struct uverbs_attr_bundle *attrs,
return PTR_ERR_OR_ZERO(obj); return PTR_ERR_OR_ZERO(obj);
} }
static ssize_t ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_resize_cq cmd; struct ib_uverbs_resize_cq cmd;
struct ib_uverbs_resize_cq_resp resp = {}; struct ib_uverbs_resize_cq_resp resp = {};
...@@ -1189,7 +1174,7 @@ static ssize_t ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs, ...@@ -1189,7 +1174,7 @@ static ssize_t ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs,
out: out:
uobj_put_obj_read(cq); uobj_put_obj_read(cq);
return ret ? ret : in_len; return ret;
} }
static int copy_wc_to_user(struct ib_device *ib_dev, void __user *dest, static int copy_wc_to_user(struct ib_device *ib_dev, void __user *dest,
...@@ -1222,9 +1207,8 @@ static int copy_wc_to_user(struct ib_device *ib_dev, void __user *dest, ...@@ -1222,9 +1207,8 @@ static int copy_wc_to_user(struct ib_device *ib_dev, void __user *dest,
return 0; return 0;
} }
static ssize_t ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_poll_cq cmd; struct ib_uverbs_poll_cq cmd;
struct ib_uverbs_poll_cq_resp resp; struct ib_uverbs_poll_cq_resp resp;
...@@ -1266,14 +1250,14 @@ static ssize_t ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs, ...@@ -1266,14 +1250,14 @@ static ssize_t ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs,
goto out_put; goto out_put;
} }
ret = in_len; ret = 0;
out_put: out_put:
uobj_put_obj_read(cq); uobj_put_obj_read(cq);
return ret; return ret;
} }
static ssize_t ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -1292,12 +1276,11 @@ static ssize_t ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs, ...@@ -1292,12 +1276,11 @@ static ssize_t ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs,
uobj_put_obj_read(cq); uobj_put_obj_read(cq);
return in_len; return 0;
} }
static ssize_t ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_destroy_cq cmd; struct ib_uverbs_destroy_cq cmd;
struct ib_uverbs_destroy_cq_resp resp; struct ib_uverbs_destroy_cq_resp resp;
...@@ -1321,7 +1304,7 @@ static ssize_t ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs, ...@@ -1321,7 +1304,7 @@ static ssize_t ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp)) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp))
return -EFAULT; return -EFAULT;
return in_len; return 0;
} }
static int create_qp(struct uverbs_attr_bundle *attrs, static int create_qp(struct uverbs_attr_bundle *attrs,
...@@ -1578,7 +1561,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1578,7 +1561,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
if (ind_tbl) if (ind_tbl)
uobj_put_obj_read(ind_tbl); uobj_put_obj_read(ind_tbl);
return uobj_alloc_commit(&obj->uevent.uobject, 0); return uobj_alloc_commit(&obj->uevent.uobject);
err_cb: err_cb:
ib_destroy_qp(qp); ib_destroy_qp(qp);
...@@ -1610,9 +1593,8 @@ static int ib_uverbs_create_qp_cb(struct uverbs_attr_bundle *attrs, ...@@ -1610,9 +1593,8 @@ static int ib_uverbs_create_qp_cb(struct uverbs_attr_bundle *attrs,
return 0; return 0;
} }
static ssize_t ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_create_qp cmd; struct ib_uverbs_create_qp cmd;
struct ib_uverbs_ex_create_qp cmd_ex; struct ib_uverbs_ex_create_qp cmd_ex;
...@@ -1657,7 +1639,7 @@ static ssize_t ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1657,7 +1639,7 @@ static ssize_t ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs,
if (err) if (err)
return err; return err;
return in_len; return 0;
} }
static int ib_uverbs_ex_create_qp_cb(struct uverbs_attr_bundle *attrs, static int ib_uverbs_ex_create_qp_cb(struct uverbs_attr_bundle *attrs,
...@@ -1705,9 +1687,8 @@ static int ib_uverbs_ex_create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1705,9 +1687,8 @@ static int ib_uverbs_ex_create_qp(struct uverbs_attr_bundle *attrs,
return 0; return 0;
} }
static ssize_t ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_open_qp cmd; struct ib_uverbs_open_qp cmd;
struct ib_uverbs_create_qp_resp resp; struct ib_uverbs_create_qp_resp resp;
...@@ -1780,7 +1761,7 @@ static ssize_t ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs, ...@@ -1780,7 +1761,7 @@ static ssize_t ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs,
qp->uobject = &obj->uevent.uobject; qp->uobject = &obj->uevent.uobject;
uobj_put_read(xrcd_uobj); uobj_put_read(xrcd_uobj);
return uobj_alloc_commit(&obj->uevent.uobject, in_len); return uobj_alloc_commit(&obj->uevent.uobject);
err_destroy: err_destroy:
ib_destroy_qp(qp); ib_destroy_qp(qp);
...@@ -1813,9 +1794,8 @@ static void copy_ah_attr_to_uverbs(struct ib_uverbs_qp_dest *uverb_attr, ...@@ -1813,9 +1794,8 @@ static void copy_ah_attr_to_uverbs(struct ib_uverbs_qp_dest *uverb_attr,
uverb_attr->port_num = rdma_ah_get_port_num(rdma_attr); uverb_attr->port_num = rdma_ah_get_port_num(rdma_attr);
} }
static ssize_t ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_query_qp cmd; struct ib_uverbs_query_qp cmd;
struct ib_uverbs_query_qp_resp resp; struct ib_uverbs_query_qp_resp resp;
...@@ -1888,7 +1868,7 @@ static ssize_t ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs, ...@@ -1888,7 +1868,7 @@ static ssize_t ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs,
kfree(attr); kfree(attr);
kfree(init_attr); kfree(init_attr);
return ret ? ret : in_len; return ret;
} }
/* Remove ignored fields set in the attribute mask */ /* Remove ignored fields set in the attribute mask */
...@@ -2087,13 +2067,11 @@ static int modify_qp(struct uverbs_attr_bundle *attrs, ...@@ -2087,13 +2067,11 @@ static int modify_qp(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_ex_modify_qp cmd = {}; struct ib_uverbs_ex_modify_qp cmd = {};
struct ib_udata udata; struct ib_udata udata;
int ret;
if (copy_from_user(&cmd.base, buf, sizeof(cmd.base))) if (copy_from_user(&cmd.base, buf, sizeof(cmd.base)))
return -EFAULT; return -EFAULT;
...@@ -2106,11 +2084,7 @@ static ssize_t ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs, ...@@ -2106,11 +2084,7 @@ static ssize_t ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs,
in_len - sizeof(cmd.base) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd.base) - sizeof(struct ib_uverbs_cmd_hdr),
out_len); out_len);
ret = modify_qp(attrs, &cmd, &udata); return modify_qp(attrs, &cmd, &udata);
if (ret)
return ret;
return in_len;
} }
static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs,
...@@ -2147,9 +2121,8 @@ static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs, ...@@ -2147,9 +2121,8 @@ static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_destroy_qp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_destroy_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_destroy_qp cmd; struct ib_uverbs_destroy_qp cmd;
struct ib_uverbs_destroy_qp_resp resp; struct ib_uverbs_destroy_qp_resp resp;
...@@ -2172,7 +2145,7 @@ static ssize_t ib_uverbs_destroy_qp(struct uverbs_attr_bundle *attrs, ...@@ -2172,7 +2145,7 @@ static ssize_t ib_uverbs_destroy_qp(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp)) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp))
return -EFAULT; return -EFAULT;
return in_len; return 0;
} }
static void *alloc_wr(size_t wr_size, __u32 num_sge) static void *alloc_wr(size_t wr_size, __u32 num_sge)
...@@ -2185,9 +2158,8 @@ static void *alloc_wr(size_t wr_size, __u32 num_sge) ...@@ -2185,9 +2158,8 @@ static void *alloc_wr(size_t wr_size, __u32 num_sge)
num_sge * sizeof (struct ib_sge), GFP_KERNEL); num_sge * sizeof (struct ib_sge), GFP_KERNEL);
} }
static ssize_t ib_uverbs_post_send(struct uverbs_attr_bundle *attrs, static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_post_send cmd; struct ib_uverbs_post_send cmd;
struct ib_uverbs_post_send_resp resp; struct ib_uverbs_post_send_resp resp;
...@@ -2370,7 +2342,7 @@ static ssize_t ib_uverbs_post_send(struct uverbs_attr_bundle *attrs, ...@@ -2370,7 +2342,7 @@ static ssize_t ib_uverbs_post_send(struct uverbs_attr_bundle *attrs,
out: out:
kfree(user_wr); kfree(user_wr);
return ret ? ret : in_len; return ret;
} }
static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf, static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
...@@ -2465,9 +2437,8 @@ static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf, ...@@ -2465,9 +2437,8 @@ static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
static ssize_t ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs, static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_post_recv cmd; struct ib_uverbs_post_recv cmd;
struct ib_uverbs_post_recv_resp resp; struct ib_uverbs_post_recv_resp resp;
...@@ -2511,10 +2482,10 @@ static ssize_t ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs, ...@@ -2511,10 +2482,10 @@ static ssize_t ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs,
wr = next; wr = next;
} }
return ret ? ret : in_len; return ret;
} }
static ssize_t ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs, static int ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -2560,12 +2531,11 @@ static ssize_t ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs, ...@@ -2560,12 +2531,11 @@ static ssize_t ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs,
wr = next; wr = next;
} }
return ret ? ret : in_len; return ret;
} }
static ssize_t ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs, static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_create_ah cmd; struct ib_uverbs_create_ah cmd;
struct ib_uverbs_create_ah_resp resp; struct ib_uverbs_create_ah_resp resp;
...@@ -2639,7 +2609,7 @@ static ssize_t ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs, ...@@ -2639,7 +2609,7 @@ static ssize_t ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
} }
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(uobj, in_len); return uobj_alloc_commit(uobj);
err_copy: err_copy:
rdma_destroy_ah(ah); rdma_destroy_ah(ah);
...@@ -2652,20 +2622,18 @@ static ssize_t ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs, ...@@ -2652,20 +2622,18 @@ static ssize_t ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_destroy_ah(struct uverbs_attr_bundle *attrs, static int ib_uverbs_destroy_ah(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_destroy_ah cmd; struct ib_uverbs_destroy_ah cmd;
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
return uobj_perform_destroy(UVERBS_OBJECT_AH, cmd.ah_handle, attrs, return uobj_perform_destroy(UVERBS_OBJECT_AH, cmd.ah_handle, attrs);
in_len);
} }
static ssize_t ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs, static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -2711,10 +2679,10 @@ static ssize_t ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs, ...@@ -2711,10 +2679,10 @@ static ssize_t ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs,
mutex_unlock(&obj->mcast_lock); mutex_unlock(&obj->mcast_lock);
uobj_put_obj_read(qp); uobj_put_obj_read(qp);
return ret ? ret : in_len; return ret;
} }
static ssize_t ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs, static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -2754,7 +2722,7 @@ static ssize_t ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs, ...@@ -2754,7 +2722,7 @@ static ssize_t ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs,
out_put: out_put:
mutex_unlock(&obj->mcast_lock); mutex_unlock(&obj->mcast_lock);
uobj_put_obj_read(qp); uobj_put_obj_read(qp);
return ret ? ret : in_len; return ret;
} }
struct ib_uflow_resources *flow_resources_alloc(size_t num_specs) struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
...@@ -3173,7 +3141,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs, ...@@ -3173,7 +3141,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs,
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
uobj_put_obj_read(cq); uobj_put_obj_read(cq);
return uobj_alloc_commit(&obj->uevent.uobject, 0); return uobj_alloc_commit(&obj->uevent.uobject);
err_copy: err_copy:
ib_destroy_wq(wq); ib_destroy_wq(wq);
...@@ -3399,7 +3367,7 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs, ...@@ -3399,7 +3367,7 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs,
for (j = 0; j < num_read_wqs; j++) for (j = 0; j < num_read_wqs; j++)
uobj_put_obj_read(wqs[j]); uobj_put_obj_read(wqs[j]);
return uobj_alloc_commit(uobj, 0); return uobj_alloc_commit(uobj);
err_copy: err_copy:
ib_destroy_rwq_ind_table(rwq_ind_tbl); ib_destroy_rwq_ind_table(rwq_ind_tbl);
...@@ -3440,7 +3408,7 @@ static int ib_uverbs_ex_destroy_rwq_ind_table(struct uverbs_attr_bundle *attrs, ...@@ -3440,7 +3408,7 @@ static int ib_uverbs_ex_destroy_rwq_ind_table(struct uverbs_attr_bundle *attrs,
return -EOPNOTSUPP; return -EOPNOTSUPP;
return uobj_perform_destroy(UVERBS_OBJECT_RWQ_IND_TBL, return uobj_perform_destroy(UVERBS_OBJECT_RWQ_IND_TBL,
cmd.ind_tbl_handle, attrs, 0); cmd.ind_tbl_handle, attrs);
} }
static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs, static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs,
...@@ -3598,7 +3566,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs, ...@@ -3598,7 +3566,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs,
kfree(flow_attr); kfree(flow_attr);
if (cmd.flow_attr.num_of_specs) if (cmd.flow_attr.num_of_specs)
kfree(kern_flow_attr); kfree(kern_flow_attr);
return uobj_alloc_commit(uobj, 0); return uobj_alloc_commit(uobj);
err_copy: err_copy:
if (!qp->device->destroy_flow(flow_id)) if (!qp->device->destroy_flow(flow_id))
atomic_dec(&qp->usecnt); atomic_dec(&qp->usecnt);
...@@ -3633,8 +3601,7 @@ static int ib_uverbs_ex_destroy_flow(struct uverbs_attr_bundle *attrs, ...@@ -3633,8 +3601,7 @@ static int ib_uverbs_ex_destroy_flow(struct uverbs_attr_bundle *attrs,
if (cmd.comp_mask) if (cmd.comp_mask)
return -EINVAL; return -EINVAL;
return uobj_perform_destroy(UVERBS_OBJECT_FLOW, cmd.flow_handle, attrs, return uobj_perform_destroy(UVERBS_OBJECT_FLOW, cmd.flow_handle, attrs);
0);
} }
static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
...@@ -3750,7 +3717,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3750,7 +3717,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
uobj_put_obj_read(attr.ext.cq); uobj_put_obj_read(attr.ext.cq);
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
return uobj_alloc_commit(&obj->uevent.uobject, 0); return uobj_alloc_commit(&obj->uevent.uobject);
err_copy: err_copy:
ib_destroy_srq(srq); ib_destroy_srq(srq);
...@@ -3773,15 +3740,13 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3773,15 +3740,13 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
return ret; return ret;
} }
static ssize_t ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_create_srq cmd; struct ib_uverbs_create_srq cmd;
struct ib_uverbs_create_xsrq xcmd; struct ib_uverbs_create_xsrq xcmd;
struct ib_uverbs_create_srq_resp resp; struct ib_uverbs_create_srq_resp resp;
struct ib_udata udata; struct ib_udata udata;
int ret;
if (out_len < sizeof resp) if (out_len < sizeof resp)
return -ENOSPC; return -ENOSPC;
...@@ -3803,21 +3768,16 @@ static ssize_t ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs, ...@@ -3803,21 +3768,16 @@ static ssize_t ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs,
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp)); out_len - sizeof(resp));
ret = __uverbs_create_xsrq(attrs, &xcmd, &udata); return __uverbs_create_xsrq(attrs, &xcmd, &udata);
if (ret)
return ret;
return in_len;
} }
static ssize_t ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
struct ib_uverbs_create_xsrq cmd; struct ib_uverbs_create_xsrq cmd;
struct ib_uverbs_create_srq_resp resp; struct ib_uverbs_create_srq_resp resp;
struct ib_udata udata; struct ib_udata udata;
int ret;
if (out_len < sizeof resp) if (out_len < sizeof resp)
return -ENOSPC; return -ENOSPC;
...@@ -3830,16 +3790,11 @@ static ssize_t ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3830,16 +3790,11 @@ static ssize_t ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp)); out_len - sizeof(resp));
ret = __uverbs_create_xsrq(attrs, &cmd, &udata); return __uverbs_create_xsrq(attrs, &cmd, &udata);
if (ret)
return ret;
return in_len;
} }
static ssize_t ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_modify_srq cmd; struct ib_uverbs_modify_srq cmd;
struct ib_udata udata; struct ib_udata udata;
...@@ -3864,12 +3819,11 @@ static ssize_t ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs, ...@@ -3864,12 +3819,11 @@ static ssize_t ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs,
uobj_put_obj_read(srq); uobj_put_obj_read(srq);
return ret ? ret : in_len; return ret;
} }
static ssize_t ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
struct ib_uverbs_query_srq cmd; struct ib_uverbs_query_srq cmd;
struct ib_uverbs_query_srq_resp resp; struct ib_uverbs_query_srq_resp resp;
...@@ -3903,10 +3857,10 @@ static ssize_t ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs, ...@@ -3903,10 +3857,10 @@ static ssize_t ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp)) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof resp))
return -EFAULT; return -EFAULT;
return in_len; return 0;
} }
static ssize_t ib_uverbs_destroy_srq(struct uverbs_attr_bundle *attrs, static int ib_uverbs_destroy_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len) int out_len)
{ {
...@@ -3931,7 +3885,7 @@ static ssize_t ib_uverbs_destroy_srq(struct uverbs_attr_bundle *attrs, ...@@ -3931,7 +3885,7 @@ static ssize_t ib_uverbs_destroy_srq(struct uverbs_attr_bundle *attrs,
if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof(resp))) if (copy_to_user(u64_to_user_ptr(cmd.response), &resp, sizeof(resp)))
return -EFAULT; return -EFAULT;
return in_len; return 0;
} }
static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs, static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs,
......
...@@ -688,11 +688,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, ...@@ -688,11 +688,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
ex_hdr.provider_out_words * 8); ex_hdr.provider_out_words * 8);
ret = method_elm->handler_ex(&bundle, &ucore, &uhw); ret = method_elm->handler_ex(&bundle, &ucore, &uhw);
ret = (ret) ? : count;
} }
srcu_read_unlock(&file->device->disassociate_srcu, srcu_key); srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
return ret; return (ret) ? : count;
} }
static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma) static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
......
...@@ -8,9 +8,8 @@ ...@@ -8,9 +8,8 @@
#include "rdma_core.h" #include "rdma_core.h"
#include "uverbs.h" #include "uverbs.h"
static ssize_t ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -368,7 +368,7 @@ struct uapi_definition { ...@@ -368,7 +368,7 @@ struct uapi_definition {
union { union {
bool (*func_is_supported)(struct ib_device *device); bool (*func_is_supported)(struct ib_device *device);
ssize_t (*func_write)(struct uverbs_attr_bundle *attrs, int (*func_write)(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len); int out_len);
int (*func_write_ex)(struct uverbs_attr_bundle *attrs, int (*func_write_ex)(struct uverbs_attr_bundle *attrs,
......
...@@ -72,11 +72,10 @@ static inline void *_uobj_get_obj_read(struct ib_uobject *uobj) ...@@ -72,11 +72,10 @@ static inline void *_uobj_get_obj_read(struct ib_uobject *uobj)
_uobj_check_id(_id), UVERBS_LOOKUP_WRITE) _uobj_check_id(_id), UVERBS_LOOKUP_WRITE)
int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id, int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
const struct uverbs_attr_bundle *attrs, const struct uverbs_attr_bundle *attrs);
int success_res); #define uobj_perform_destroy(_type, _id, _attrs) \
#define uobj_perform_destroy(_type, _id, _attrs, _success_res) \
__uobj_perform_destroy(uobj_get_type(_attrs, _type), \ __uobj_perform_destroy(uobj_get_type(_attrs, _type), \
_uobj_check_id(_id), _attrs, _success_res) _uobj_check_id(_id), _attrs)
struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj, struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
u32 id, u32 id,
...@@ -104,14 +103,13 @@ static inline void uobj_put_write(struct ib_uobject *uobj) ...@@ -104,14 +103,13 @@ static inline void uobj_put_write(struct ib_uobject *uobj)
rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE);
} }
static inline int __must_check uobj_alloc_commit(struct ib_uobject *uobj, static inline int __must_check uobj_alloc_commit(struct ib_uobject *uobj)
int success_res)
{ {
int ret = rdma_alloc_commit_uobject(uobj); int ret = rdma_alloc_commit_uobject(uobj);
if (ret) if (ret)
return ret; return ret;
return success_res; return 0;
} }
static inline void uobj_alloc_abort(struct ib_uobject *uobj) static inline void uobj_alloc_abort(struct ib_uobject *uobj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment