|
@@ -736,10 +736,6 @@ 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) {
|
|
|
if (count < (sizeof(hdr) + sizeof(ex_hdr)))
|
|
|
return -EINVAL;
|
|
@@ -759,6 +755,16 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * Must be after the ib_dev check, as once the RCU clears ib_dev ==
|
|
|
+ * NULL means ucontext == NULL
|
|
|
+ */
|
|
|
+ if (!file->ucontext &&
|
|
|
+ (command != IB_USER_VERBS_CMD_GET_CONTEXT || extended)) {
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
if (!verify_command_mask(ib_dev, command, extended)) {
|
|
|
ret = -EOPNOTSUPP;
|
|
|
goto out;
|