]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ptp: use memdup_user().
authorMuhammad Falak R Wani <falakreyaz@gmail.com>
Fri, 20 May 2016 12:21:02 +0000 (17:51 +0530)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 May 2016 21:05:30 +0000 (14:05 -0700)
Use memdup_user to duplicate a memory region from user-space to
kernel-space, instead of open coding using kmalloc & copy_from_user.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ptp/ptp_chardev.c

index 579fd65299a0cfc18b98e8e51a619e26bf82945f..0b1ac6be69ce8d2a73d58432badb7bf7262ad5b6 100644 (file)
@@ -208,14 +208,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
                break;
 
        case PTP_SYS_OFFSET:
-               sysoff = kmalloc(sizeof(*sysoff), GFP_KERNEL);
-               if (!sysoff) {
-                       err = -ENOMEM;
-                       break;
-               }
-               if (copy_from_user(sysoff, (void __user *)arg,
-                                  sizeof(*sysoff))) {
-                       err = -EFAULT;
+               sysoff = memdup_user((void __user *)arg, sizeof(*sysoff));
+               if (IS_ERR(sysoff)) {
+                       err = PTR_ERR(sysoff);
                        break;
                }
                if (sysoff->n_samples > PTP_MAX_SAMPLES) {