staging: lustre: obdclass: return -EFAULT if copy_from_user() fails
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 26 Aug 2017 06:04:18 +0000 (09:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Aug 2017 08:24:06 +0000 (10:24 +0200)
The copy_from_user() function returns the number of bytes which we
weren't able to copy.  We don't want to return that to the user but
instead we want to return -EFAULT.

Fixes: d7e09d0397e8 ("staging: add Lustre file system client support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/class_obd.c

index 8ad3adb2ceb10866cccca239c39433ac1bf290ff..5453589232716c7580aa60c01d3231ccb31b9c54 100644 (file)
@@ -180,7 +180,8 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                        err = -ENOMEM;
                        goto out;
                }
-               err = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1);
+               if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
+                       err = -EFAULT;
                if (!err)
                        err = lustre_cfg_sanity_check(lcfg, data->ioc_plen1);
                if (!err)