Skip to content

Commit

Permalink
RDMA/uverbs: Move uncontext check before SRCU read lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Leon Romanovsky authored and Doug Ledford committed Feb 23, 2018
1 parent eb455e3 commit 491d5c6
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 491d5c6

Please sign in to comment.