aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2018-02-21 18:12:39 +0200
committerDoug Ledford <dledford@redhat.com>2018-02-22 22:29:50 -0500
commit491d5c6a3023e303cc693b91d9b3a4d54471c944 (patch)
tree347a613a6f8d92bf4ae2471cdab3c268d9852f30 /drivers/infiniband
parentRDMA/uverbs: Properly check command supported mask (diff)
downloadlinux-dev-491d5c6a3023e303cc693b91d9b3a4d54471c944.tar.xz
linux-dev-491d5c6a3023e303cc693b91d9b3a4d54471c944.zip
RDMA/uverbs: Move uncontext check before SRCU read lock
There is no need to take SRCU lock before checking file->ucontext, so move it do it before it. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to '')
-rw-r--r--drivers/infiniband/core/uverbs_main.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 1f2fd839953f..ff70e1ead1ba 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -705,6 +705,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
if (ret)
return ret;
+ if (!file->ucontext &&
+ (command != IB_USER_VERBS_CMD_GET_CONTEXT || extended))
+ return -EINVAL;
+
if (extended && count < (sizeof(hdr) + sizeof(ex_hdr)))
return -EINVAL;
@@ -721,12 +725,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
goto out;
}
- if (!file->ucontext &&
- command != IB_USER_VERBS_CMD_GET_CONTEXT) {
- ret = -EINVAL;
- goto out;
- }
-
if (!extended) {
if (hdr.in_words * 4 != count) {
ret = -EINVAL;
@@ -742,11 +740,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
struct ib_udata uhw;
size_t written_count = count;
- if (!file->ucontext) {
- ret = -EINVAL;
- goto out;
- }
-
if (copy_from_user(&ex_hdr, buf + sizeof(hdr), sizeof(ex_hdr))) {
ret = -EFAULT;
goto out;