Skip to content

Commit e23ef22

Browse files
error27johnstultz-work
authored andcommitted
ptp: Return -EFAULT on copy_to_user() errors
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>
1 parent 1fa7b6a commit e23ef22

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/ptp/ptp_chardev.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
4646
caps.n_ext_ts = ptp->info->n_ext_ts;
4747
caps.n_per_out = ptp->info->n_per_out;
4848
caps.pps = ptp->info->pps;
49-
err = copy_to_user((void __user *)arg, &caps, sizeof(caps));
49+
if (copy_to_user((void __user *)arg, &caps, sizeof(caps)))
50+
err = -EFAULT;
5051
break;
5152

5253
case PTP_EXTTS_REQUEST:

0 commit comments

Comments
 (0)