Whamcloud - gitweb
LU-3283 llite: pass correct pointer to obd_iocontrol() 74/6274/5
authorJohn L. Hammond <john.hammond@intel.com>
Mon, 6 May 2013 21:42:32 +0000 (16:42 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 1 Aug 2013 04:04:43 +0000 (04:04 +0000)
In copy_and_ioctl() use the kernel space copy as the karg to
obd_iocontrol().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I9b714675b4b63737efc08eec1b08463de1d63d1b
Reviewed-on: http://review.whamcloud.com/6274
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Sebastien Buisson <sebastien.buisson@bull.net>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/dir.c

index 23d2af8..66ca76d 100644 (file)
@@ -1068,21 +1068,26 @@ progress:
 }
 
 
-static int copy_and_ioctl(int cmd, struct obd_export *exp, void *data, int len)
+static int copy_and_ioctl(int cmd, struct obd_export *exp,
+                         const void __user *data, size_t size)
 {
-        void *ptr;
-        int rc;
+       void *copy;
+       int rc;
 
-        OBD_ALLOC(ptr, len);
-        if (ptr == NULL)
-                return -ENOMEM;
-       if (copy_from_user(ptr, data, len)) {
-                OBD_FREE(ptr, len);
-                return -EFAULT;
-        }
-        rc = obd_iocontrol(cmd, exp, len, data, NULL);
-        OBD_FREE(ptr, len);
-        return rc;
+       OBD_ALLOC(copy, size);
+       if (copy == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(copy, data, size)) {
+               rc = -EFAULT;
+               goto out;
+       }
+
+       rc = obd_iocontrol(cmd, exp, size, copy, NULL);
+out:
+       OBD_FREE(copy, size);
+
+       return rc;
 }
 
 static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)