staging: lustre: return -EFAULT instead of bytes remaining
authorVitaly Osipov <vitaly.osipov@gmail.com>
Sun, 4 May 2014 04:14:26 +0000 (14:14 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 May 2014 23:10:41 +0000 (16:10 -0700)
return -EFAULT instead of the value returned by copy_from_user()

Signed-off-by: Vitaly Osipov <vitaly.osipov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/libcfs/linux/linux-module.c

index 9a3b07bd2fac0237e1a5eb6384d7547f1bfe319e..581b4728c6ca941ed8de221cb10fb762b7a21467 100644 (file)
@@ -45,14 +45,12 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
        struct libcfs_ioctl_hdr   *hdr;
        struct libcfs_ioctl_data  *data;
        int orig_len;
-       int err;
 
        hdr = (struct libcfs_ioctl_hdr *)buf;
        data = (struct libcfs_ioctl_data *)buf;
 
-       err = copy_from_user(buf, (void *)arg, sizeof(*hdr));
-       if (err)
-               return err;
+       if (copy_from_user(buf, (void *)arg, sizeof(*hdr)))
+               return -EFAULT;
 
        if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) {
                CERROR("PORTALS: version mismatch kernel vs application\n");
@@ -71,9 +69,8 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
        }
 
        orig_len = hdr->ioc_len;
-       err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
-       if (err)
-               return err;
+       if (copy_from_user(buf, (void *)arg, hdr->ioc_len))
+               return -EFAULT;
        if (orig_len != data->ioc_len)
                return -EINVAL;