ptp: Return -EFAULT on copy_to_user() errors
authorDan Carpenter <error27@gmail.com>
Sun, 29 May 2011 19:53:12 +0000 (22:53 +0300)
committerJohn Stultz <john.stultz@linaro.org>
Thu, 2 Jun 2011 02:29:08 +0000 (19:29 -0700)
copy_to_user() returns the number of bytes remaining, but we want a
negative error code in ptp_ioctl.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Richard Cochran <richard.cochran@omicron.at>
Signed-off-by: John Stultz <john.stultz@linaro.org>
drivers/ptp/ptp_chardev.c

index a8d03ae..93fa22d 100644 (file)
@@ -46,7 +46,8 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
                caps.n_ext_ts = ptp->info->n_ext_ts;
                caps.n_per_out = ptp->info->n_per_out;
                caps.pps = ptp->info->pps;
-               err = copy_to_user((void __user *)arg, &caps, sizeof(caps));
+               if (copy_to_user((void __user *)arg, &caps, sizeof(caps)))
+                       err = -EFAULT;
                break;
 
        case PTP_EXTTS_REQUEST: