IB/hfi1: Prevent context loss
authorIra Weiny <ira.weiny@intel.com>
Thu, 9 Jun 2016 14:51:33 +0000 (07:51 -0700)
committerDoug Ledford <dledford@redhat.com>
Sat, 18 Jun 2016 00:11:26 +0000 (20:11 -0400)
If a context has already been assigned to an FD, prevent
another assignment.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/file_ops.c

index 7a5b0e6..c702a00 100644 (file)
@@ -203,6 +203,9 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
 
        switch (cmd) {
        case HFI1_IOCTL_ASSIGN_CTXT:
+               if (uctxt)
+                       return -EINVAL;
+
                if (copy_from_user(&uinfo,
                                   (struct hfi1_user_info __user *)arg,
                                   sizeof(uinfo)))