summaryrefslogtreecommitdiff
path: root/drivers/ptp/ptp_chardev.c
diff options
context:
space:
mode:
authorMuhammad Falak R Wani <falakreyaz@gmail.com>2016-05-20 15:21:02 +0300
committerDavid S. Miller <davem@davemloft.net>2016-05-24 00:05:30 +0300
commit2ece068e1b1d6e76ecd07e04b027013e931287ff (patch)
treeed65b8a1f79facfd32b90da59f7d32c1784723a1 /drivers/ptp/ptp_chardev.c
parent8da07a393f48864a87c61bb1dfbee640d9b97fd6 (diff)
downloadlinux-2ece068e1b1d6e76ecd07e04b027013e931287ff.tar.xz
ptp: use memdup_user().
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>
Diffstat (limited to 'drivers/ptp/ptp_chardev.c')
-rw-r--r--drivers/ptp/ptp_chardev.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 579fd65299a0..0b1ac6be69ce 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -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) {