summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/uverbs_main.c
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2018-02-21 19:12:33 +0300
committerDoug Ledford <dledford@redhat.com>2018-02-23 06:29:11 +0300
commita6c4a66ae923eb780ef693a6841cbff7a025cbf9 (patch)
tree0c7b772a111cb0a8aaecdbe40fa260a794bee170 /drivers/infiniband/core/uverbs_main.c
parent08f0e161636d940ff6c8f78863ce62361291e74b (diff)
downloadlinux-a6c4a66ae923eb780ef693a6841cbff7a025cbf9.tar.xz
RDMA/uverbs: Refactor flags checks and update return value
Since commit f21519b23c1b ("IB/core: extended command: an improved infrastructure for uverbs commands"), the uverbs supports extra flags as an input to the command interface. However actually, there is only one flag available and used, so it is better to refactor the code, so the resolution and report to the users is done as early as possible. As part of this change, we changed the return value of failure case from ENOSYS to be EINVAL to be consistent with the rest flags checks. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs_main.c')
-rw-r--r--drivers/infiniband/core/uverbs_main.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 66b2f92bd47b..d28b6f1543c7 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -701,6 +701,11 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
extended_command = flags & IB_USER_VERBS_CMD_FLAG_EXTENDED;
+ if (flags & ~IB_USER_VERBS_CMD_FLAG_EXTENDED) {
+ ret = -EINVAL;
+ goto out;
+ }
+
if (!verify_command_idx(command, extended_command)) {
ret = -EINVAL;
goto out;
@@ -732,8 +737,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
buf + sizeof(hdr),
hdr.in_words * 4,
hdr.out_words * 4);
-
- } else if (flags == IB_USER_VERBS_CMD_FLAG_EXTENDED) {
+ } else {
struct ib_uverbs_ex_cmd_hdr ex_hdr;
struct ib_udata ucore;
struct ib_udata uhw;
@@ -804,8 +808,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
ret = uverbs_ex_cmd_table[command](file, ib_dev, &ucore, &uhw);
if (!ret)
ret = written_count;
- } else {
- ret = -ENOSYS;
}
out: