Commit 2ece068e authored by Muhammad Falak R Wani's avatar Muhammad Falak R Wani Committed by David S. Miller
Browse files

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: default avatarMuhammad Falak R Wani <>
Acked-by: default avatarRichard Cochran <>
Signed-off-by: default avatarDavid S. Miller <>
parent 8da07a39
......@@ -208,14 +208,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
sysoff = kmalloc(sizeof(*sysoff), GFP_KERNEL);
if (!sysoff) {
err = -ENOMEM;
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);
if (sysoff->n_samples > PTP_MAX_SAMPLES) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment