IB/core: Modify conditional on ucontext existence
authorEli Cohen <eli@mellanox.com>
Sun, 14 Feb 2016 15:07:49 +0000 (17:07 +0200)
committerDoug Ledford <dledford@redhat.com>
Thu, 3 Mar 2016 15:19:40 +0000 (10:19 -0500)
Since we allow to call legacy verbs using their extended counterpart,
the check on ucontext has to move up to a common area in case this verb
is ever extended.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/uverbs_main.c

index 20f0049db5e5c00e478c63cbc7519dbaeab5072a..8b299df0ee7b74ff093052afdf78543f08fdd1a4 100644 (file)
@@ -735,6 +735,12 @@ 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;
+       }
+
        flags = (hdr.command &
                 IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
 
@@ -745,12 +751,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 (hdr.in_words * 4 != count) {
                        ret = -EINVAL;
                        goto out;